Peter Scott wrote:
>
> > > Tony Olekshy wrote:
> > >
> > > >       try { fragile(); }
> > > >       catch { my $caught = 1; }
> > > >       finally { $caught and ... }
> > >
>
> It should work as though each pair of } ... { in between try { and
> the end of the last finally or catch block isn't there.  Storage
> for lexicals is allocated at compile time, assignment happens at
> run time.
>
> However, my memory as to what the current perl behavior is was
> faulty; continue blocks do *not* share the lexical scope of their
> attached loop blocks.
>
> So no, what I'm proposing is not the same as anything currently in
> Perl.  But I think it's a good reason anyway (and why shouldn't
> continue blocks share the same scope?  Not so 'lexical', I
> suppose.  Oh well.)

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.

Yours, &c, Tony Olekshy

Reply via email to