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

Re: [perl #113974] package NAMESPACE manpage comments

Thread Previous | Thread Next
From:
demerphq
Date:
July 6, 2012 04:35
Subject:
Re: [perl #113974] package NAMESPACE manpage comments
Message ID:
CANgJU+XoRpeLos8mH5URin0Vrua8Ev869MJto2FXwXgg2eTyZA@mail.gmail.com
On 6 July 2012 09:12, Eric Brine <ikegami@adaelis.com> wrote:
> On Fri, Jul 6, 2012 at 3:04 AM, Eric Brine <ikegami@adaelis.com> wrote:
>>
>> On Fri, Jul 6, 2012 at 1:48 AM, Linda W <perl-diddler@tlinx.org> wrote:
>>>
>>> With state both are physically scoped as well, though my is also
>>> dynamically scoped.
>>
>>
>> No, state, my and our are not dynamically scoped. They are lexically
>> scoped: They can only be seen in the current lexical scope.
>
>
>>perl -Mstrict -E"{ my $x; } $x"
> Global symbol "$x" requires explicit package name at -e line 1.
>
> Execution of -e aborted due to compilation errors.
>
>>perl -Mstrict -E"{ state $x; } $x"
> Global symbol "$x" requires explicit package name at -e line 1.
>
> Execution of -e aborted due to compilation errors.
>
>>perl -Mstrict -E"{ our $x; } $x"
> Variable "$x" is not imported at -e line 1.
> Global symbol "$x" requires explicit package name at -e line 1.
>
> Execution of -e aborted due to compilation errors.
>

A big chunk of the confusion about our and my comes from the fact that
our is not a declaration like my is. It doesnt create or reserve
storage. It is a compile hint. my on the other hand is a true
declaration. It actually creates stuff.

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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