I've moved this from perl6-language to perl6-language-flow.

Chaim Frenkel wrote:
>
> Why add another keyword. Just extend eval{} to accept two blocks.
>
>   eval { } catch { } finally { }

RFC 63 and RFC 88 are based on existing Perl 5 implementations,
so they define a subroutine called "try" to avoid the confusion
that would be caused by defining a subroutine called "eval".

If this stuff gets into the core of Perl 6, then "eval" could be
used instead of "try".  I do however think that "try" is somewhat
clearer, since that's what were doing here.

> With the catch block setting the lexical $@ to the exception.

Again, because of the existing Perl 5 implementations, RFC 63 and
RFC 88 have to internally wrap the catch clause in an eval, so
that if it throws the exception can be trapped, the finally clause
invoked, and the exception re-raised.  Inside the internal eval
$@ is cleared, so RFC 63 and RFC 88 pass the current exception to
the catch block via @_.

Yours, &c, Tony Olekshy

Reply via email to