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

RE: What's up with %MY?

Thread Previous | Thread Next
From:
Dave Mitchell
Date:
September 5, 2001 08:37
Subject:
RE: What's up with %MY?
Message ID:
200109051536.QAA11024@gizmo.fdgroup.co.uk
Dan Sugalski <dan@sidhe.org> wrote
> >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.

In either case, do people think that the behaviour should be consistent,
ie both walk or both throw?

I'm in favour walking, as long as we can get it so the walk is a one-off
fixup at delete time, and that any further accesses still just do the Perl 6 
equivalent of

PL_curpad[PL_op->op_targ]


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