At 07:24 PM 9/4/2001 -0400, Bryan C. Warnock wrote:
>On Tuesday 04 September 2001 07:25 pm, Dan Sugalski wrote:
> > Ah, but what people will want is:
> >
> >    my $x = "foo\n";
> >    {
> >      my $x = "bar\n";
> >      delete $MY::{'$x'};
> >      print $x;
> >    }
> >
> > to print foo. That's where things get tricky. Though I suppose we could
> > put some sort of placeholder with auto-backsearch capabilities. Or
> > something.
>
>Other than the obvious run-time requirements of this, what's wrong with
>simply looking in the current pad, seeing it's not there, then looking in
>the previous pad...?  (Assuming you know the variable by name....)

Absolutely nothing. The issue is speed. Looking back by name is, well, 
slow. The speed advantage that lexicals have is that we know both what pad 
a variable lives in and what offset in the pad it's living at. We don't 
have to do any runtime lookup--it's all compile time. If we lose that 
compile-time resolution, things get a lot slower. (Runtime lexical name 
lookup is a lot slower than runtime global lookup because we potentially 
have a lot of pads to walk up)

Certainly doable. Just potentially slow, which is what I'm worried about. 
Making it not slow has both potential significant complexity and memory 
usage. If we have to, that's fine. Just want to make sure the cost is known 
before the decision's made. :)

                                        Dan

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

Reply via email to