On Tue, Mar 25, 2014 at 11:31 AM, Eric Brine <ikegami@adaelis.com> wrote: > On Tue, Mar 25, 2014 at 10:48 AM, Ed Avis <eda@waniasset.com> wrote: > >> Hmm, you are right, C<{} my $x;> is also an error. >> > > Also, C<< { } { } >>. > > >> I think this is a bit fishy; in other C-like languages an empty block can >> appear in any >> place where a nonempty one can. Could that become true for Perl too? >> > > You seem to forget that { } is also the hash construction operator. { } is > far more likely to be an empty hash constructor than an empty block. You > can disambiguate by placing a ";" at the start of the block (C<< {; } >>). > In the original scenario, you could avoid the problem by commenting the > block by adding C<< if (0) >>. > > Perl could check if the "{ }" is at the start of statement, but any > statement can be an expression. > What I meant: Perl could check if the "{ }" is at the start of statement and make it a block then, but that would break code because any statement can be the start of an expression. e.g. C<< sub f { {} } >>. > Check check for void context since context isn't know yet. > What I meant: Perl can't check for void context since context isn't know yet. Sounds like something that can't be "fixed".Thread Previous | Thread Next