At 11:59 PM 8/20/00 -0600, Tony Olekshy wrote:
>RFC 88v2d6 now leaves in shared lexical scope and says the following
>under ISSUES + Lexical Scope:
>
>     If it is not possible to have try, catch, and finally blocks
>     share lexical scope (due, perhaps, to the vagaries of stack
>     unwinding), this feature can simply be deleted, and the outer
>     scope can be shared.
>
>     One possible problem is illustrated by this:
>
>         try { fragile(); }
>         catch { my $caught = 1; }
>         finally { $caught and ... }
>
>     If fragile() doesn't throw then finally is going to test
>     $caught even though the my statement was never exccuted.
>
>     These matters will have to be referred to the internals
>     experts.

The issue is not whether it is possible but whether it is desirable.  Chaim 
thought that the P5 continue block scope issue was 'fixed' by Gurusamy at 
some point and this is almost certainly correct.  Observe:

% perl5.003 -Mstrict -we 'my $x = 2; while($x--) { my $y = $x } continue { 
print "y = $y\n" }'
y = 1
y = 0
% perl5.00503 -Mstrict -we 'my $x = 2; while($x--) { my $y = $x } continue 
{ print "y = $y\n" }'
Global symbol "$y" requires explicit package name at -e line 1.
Execution of -e aborted due to compilation errors.

So the first perl had a shared scope, but it was removed by the second 
one.  Clearly the shared scope is doable, but it was considered a 
misfeature.  I will attempt to find out why.

Given that, even though we know the shared scope could be implemented, the 
implementors may prefer not to do it.  I would therefore reword:

>     We would prefer that the blocks share a common lexical scope in the 
> way that C<continue> blocks used to; if this is deemed inappropriate, 
> this feature can simply be deleted, and the outer
>     scope can be shared.

I suggest removing the rest of your quote, I don't think it adds anything.


--
Peter Scott
Pacific Systems Design Technologies

Reply via email to