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

Re: [perl #113974] package NAMESPACE manpage comments

Thread Previous | Thread Next
From:
Linda W
Date:
July 5, 2012 22:48
Subject:
Re: [perl #113974] package NAMESPACE manpage comments
Message ID:
4FF67C37.8000202@tlinx.org



` Ricardo Signes via RT wrote:
>
> When you create an alias in your package to a variable in another package, it's
> marked "imported" so that you can refer to it easily.
----
    No probe, but what alias is created with "use vars qw(aa bb));"??

I.e. to what package?  Not the current one -- since (ex.:
Same two files as before, but in file pkg.pm, I add a use vars in the 
2nd package
and then display vars:


>
> In no case does this $x become a superglobal, available without qualification
> everywhere.  It's always accessible as $Foo::x, sometimes as $x, and that's
> that.
>   
---
Yes you're right, I misinterpreted two of my lines...

So what I hoped at first, was that 'use vars', then is REALLY the way to 
get a
package variable that is only tied to that package and doesn't wander to 
other
packages based on physical scope unless they specifically prefix it.

To me,  even though 'use vars' is more cumbersome to use, it's a 
logical, name space
partitioned variable, while "our" is a physically partitioned variable 
that is named from the current name space.

> "our" variables are available by short name in the enclosing lexical scope.
>   
How do you get from physical scoping to the word lexical which means "of 
the grammar or language?...Tried to look up derivation of lexical, and I 
don't see the relation to it's original meaning... almost like someone 
used it not knowing the.


In this case it is a physical scoping vs. a logical scoping.

With state both are physically scoped as well, though my is also 
dynamically scoped.

I think those are the differences and terms that need to be emphasized 
and used.

Please correct this if you think it is wrong:

Scoping 	Physical 	logical 	Dynamic
Type 	-------- 	----------- 	-----------
my 	yes 	no 	yes
state 	yes 	no 	no
our 	yes 	partial 	no
local 	no 	no 	yes
use_vars 	no
	yes 	no 	



> "use vars" variables are available by short name whenever in the importing
> package.
>   
---
but not different packages, right?



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