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

Re: [perl #113974] package NAMESPACE manpage comments

Thread Previous | Thread Next
Eric Brine
July 6, 2012 08:19
Re: [perl #113974] package NAMESPACE manpage comments
Message ID:
On Fri, Jul 6, 2012 at 4:30 AM, Linda W <> wrote:

>  'my' has dynamic scope

No, it does not. Contrast with local which provides dynamic scoping:

>perl -E"sub f { say $x } { my $x = 123; f() }"

>perl -E"sub f { say $x } { local $x = 123; f() }"

> in the it goes away at end of the physical boundaries (sans any references
> to it).

Yes, that's called lexical scoping. or static scoping. Did you follow the
link I gave?

> It also dynamically is created when you enter the physical boundaries of
> it's lexical scope.

Scope has nothing to do with where are variable is created. Scope is
entirely about where it's visible.

You're also completely wrong about where and when it's created. A "my"
variable is created at run-tine, and either cleared or recreated on scope

> It's a new var at that point.


> Such isn't true with state or our.

Not so. Equally new var there. A variable is an association between a name
and an address. "state", "our", and "my" equally create variables.

You seem to be confusing "scope" with "allocation".

- Eric

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About