develooper Front page | perl.perl5.porters | Postings from September 2016

Re: [perl #129345] perlmod doc bug wrt package scope

Thread Previous | Thread Next
From:
David Nicol
Date:
September 25, 2016 01:22
Subject:
Re: [perl #129345] perlmod doc bug wrt package scope
Message ID:
CAFwScO8eXC+oiq4aDDT4JBKus8aZj2yM2mSukyy-80iVyN2xDA@mail.gmail.com
thanks for this explanation! I too thought package replaced rather
than nested, and I was surprised to see this output:

$ perl -le 'package a; { print __PACKAGE__; package b;  print
__PACKAGE__; } print __PACKAGE__;'
a
b
a


I was expecting a, b, b. Was it initially broken, like in perl 5.0.0?

Anyway, some kind of improvement to the documentation of this makes
sense as it currently can be misinterpreted.

dln




On Sat, Sep 24, 2016 at 4:56 PM, Zefram <zefram@fysh.org> wrote:
> via RT wrote:
>>Does not mention that package scope ends at next package statement.
>
> It doesn't: the next package statement produces a nested package scope.
> The two scopes happen to have the same end point, so it's just a bit
> difficult to discern.
>
>>my() variable scopes cross package statement boundaries.
>
> Nested again.  You have a package scope inside a my scope inside a
> package scope.
>
> -zefram



-- 
"Teaching radical novelties is our main safeguard against
dictatorships" -- Edsger W. Dijkstra

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