develooper Front page | perl.perl5.porters | Postings from April 2012

Re: proposal: functional C<if>

Thread Previous | Thread Next
From:
Abigail
Date:
April 26, 2012 04:48
Subject:
Re: proposal: functional C<if>
Message ID:
20120426114923.GB25033@almanda
On Wed, Apr 25, 2012 at 04:27:38PM -0500, David Nicol wrote:
> 
> Challenge: Can anyone come up with an ambiguous expression where it is
> not clear if the expression is supposed to be an R-value if-statement
> (were such things allowed) or a trailing conditional?

Yes and no.

Consider:

    push @x => "foo", if (1) {"bar"} else {"baz"};

this isn't ambiguous if you look at it as a whole, but it is ambiguous
the moment the parser encounters the "if", and it cannot unambiguate it
by looking one token (or any fixed amount of tokens) ahead -- it actually
will have to look at the token past the ')' to do so.



Abigail

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About