develooper Front page | perl.perl5.porters | Postings from March 2014

RE: [perl #121501] Empty code block {} causes syntax error(misparsed as anonymous hash constructor?) before 'sub'

Thread Previous | Thread Next
From:
Ed Avis
Date:
March 25, 2014 15:38
Subject:
RE: [perl #121501] Empty code block {} causes syntax error(misparsed as anonymous hash constructor?) before 'sub'
Message ID:
7E039918541B4C4183BFDB8F015C7430697851@WCL-EXCH02.wcl.local
Eric Brine wrote:

>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 {  {}  } >>.

Right.  Which is why I suggest only changing the parsing in cases where it is
currently a syntax error: in other words try to parse using the current rules,
but if these rules guess that {} is an anonymous hash constructor and this
gives a syntax error, backtrack and parse it as an empty block instead.
That wouldn't break any existing code, but I don't know how practical it is.

-- 
Ed Avis <eda@waniasset.com>

______________________________________________________________________
This email has been scanned by the Symantec Email Security.cloud service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________

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