develooper Front page | perl.perl6.language | Postings from September 2001

RE: What's up with %MY?

Thread Previous | Thread Next
From:
Dan Sugalski
Date:
September 5, 2001 08:11
Subject:
RE: What's up with %MY?
Message ID:
5.1.0.14.2.20010905104618.020787d8@pop.sidhe.org
At 01:45 PM 9/5/2001 +0100, Dave Mitchell wrote:
>can I just clarify something about delete:
>
>my $x = 1;
>{
>     my $x = 2;
>     delete $MY::{'$x'};
>     print $x;
>     $mysub = sub {$x};
>}
>
>print $mysub->();
>
>People seem agreed that print $x should do the equivalent of
>         throw "lexical '$x' no longer in scope"

There might be less agreement than you might think. I wouldn't consider it 
unreasonable to search outward until I found a $x. (Perhaps going so far as 
to find a global if there were no lexical $x around)

>rather than printing 1, but what should print $mysub->() do?

Whatever inside would do, either throwing the error or walking out. I can 
see either way.

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                      teddy bears get drunk


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