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

[perl #122782] Some statements not permitted in map block

Thread Previous
From:
Father Chrysostomos via RT
Date:
October 25, 2014 18:06
Subject:
[perl #122782] Some statements not permitted in map block
Message ID:
rt-4.0.18-15369-1414260375-1435.122782-15-0@perl.org
On Sun Sep 14 22:53:04 2014, sprout wrote:
> While this would take care of map {{ .... }} and map {no ...}.  But
> what about map{BEGIN...}?  The current behaviour is to treat BEGIN as
> not-a-keyword unless it is at the beginning of a statement (more
> precisely, unless PL_expect is XSTATE).  Is it acceptable to break
> that?
> 
> $ ./perl -Ilib -le 'print for map {BEGIN . $_} 3..5'
> BEGIN3
> BEGIN4
> BEGIN5

Nothing on CPAN matches /(printf?|say|map|grep)\s*\{\s*(BEGIN|AUTOLOAD|UNITCHECK|DESTROY|END|INIT|CHECK)\b/, nor can I think of any real use for this, so I think it is acceptable.

> Also, setting PL_expect to XSTATE will allow pod where we did not
> allow it before:
> 
> map {
> =cut
> blah blah blah
> =cut
> {...} }
> 
> but it would be very hard to see through the pod to detect the opening
> brace (based on the current pod implementation, though I am wondering
> whether changing the implementation to make this work would actually
> simplify it).  And presumably that example should behave the same way
> as this:
> 
> map {
> # a multiline
> # comment that actually
>  # consists of multiple
> # single-line comments
> {...} }
> 
> Or at least one might expect it to.

Or maybe not, since pod is only allowed at the beginning of a statement, so it currently is not treated as just whitespace.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=122782

Thread Previous


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