[EMAIL PROTECTED] (Nathan Wiger) wrote on 14.08.00 in <[EMAIL PROTECTED]>:
> Well, lexical variables don't belong to any package in Perl. They're not
> in the symbol table, hence why others can't mess with them. That's why a
> "my $var" is different from a "$pkg::var". The latter gets in the symbol
> table, the former doesn't.
I think Perl'd profit from using a structure similar to the following:
1. Package variables $package::var, presumably you'd have to declare those
and the default would be
2. lexical variables,
except that different from the current way, you'd have access to a stack
of lexical symbol tables. (Doesn't mean it needs to be the same
datastructure internally, just so long as you can access it with the same
syntax.)
So you'd find a global var via $package::{'var'}, and a lexical var via
$STACK[3]{'var'} ($STACK[0] being where my() declares new variables, and
$STACK[$#STACK] the symbol table where top-level my() declares file-scope
variables).
Except for access to the symbol table, that's very similar to what other
languages have.
Furthermore, in the "more rope" department, it might be possible to make
local() work on my() variables this way.
MfG Kai