At 05:44 PM 9/3/2001 -0400, Ken Fox wrote:
>Brent Dax wrote:
> > What I'm suggesting is that, instead of the padlist's AV containing
> > arrays, it should contain stashes, otherwise indistinguishable from
> > the ones used for global variables.
>
>Lexicals are fundamentally different from Perl's package (dynamically
>scoped) variables. Even if you could somehow hack package variables
>to implement lexicals, it would waste space duplicating a symbol table
>for each instance of a lexical scope.

No, actually, they're not.

The big difference between lexical variables and package variables is that 
lexicals are looked up by stash offset and package variables are looked up 
by name. (Okay, there are a few minor details beyond that, but that's 
really the big one) There really isn't anything special about a stash. All 
it is is a hash perl thinks contains variable names. (And it has GVs 
instead of [SHA]Vs, but once again a trivial difference, and one going away 
for perl 6)

The real question, as I see it, is "Should we look lexicals up by name?" 
And the answer is Yes. Larry's decreed it, and it makes sense. (I'm 
half-tempted to hack up something to let it be done in perl 5--wouldn't 
take much work)

The less real question, "Should pads be hashes or arrays", can be answered 
by "whichever is ultimately cheaper". My bet is we'll probably keep the 
array structure with embedded names, and do a linear search for those rare 
times you're actually looking by name.

                                        Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to