At 02:08 PM 8/1/00 -0400, Dan Sugalski wrote:
>At 06:59 PM 8/1/00 +0100, Hildo Biersma wrote:
>
>>Can you imagine doing this for 'local'?  That would lead to some pretty
>>neat obfuscated code...
>
>Sure. long_distance($var, -1) could give the most-recently-localized 
>version of $var. :-)
>
>I'd rather not do it for globals, though. (Actually I'd be just as happy 
>to see local go missing entirely, but that's just me looking at the guts...)

I haven't looked at the internals for local, but isn't:

{
   local $foo;

   ...
}

effectively syntactic sugar for:

{
   my $unnamed_foo = $foo;     # $unnamed_foo not accessible

   ...

   $foo = $unnamed_foo;
}

Is there something in the behavior of local I'm missing?  If not, it might 
be useful to consider -defining- local to have that behavior, as opposed to 
it having it due to historical accident.  That might allow the problems 
with local in the internals to go away.

(It could also lead to being able to define "local" copies of package 
variables:  'local $Package::foo;' would be legal, and do the right thing.)

Reply via email to