On Thu, 2 May 2002, Jim Cromie wrote:

> 
> with p5, Ive often written
> 
> eval {} or carp "$@ blah";
> 
> it seems to work, and it reads nicer (to my eye) than
> 
> eval {}; if ($@) {}
> 
> but I surmise that it works cuz the return-value from the block is non-zero,
> for successful eval, and 0 or undef when block dies, not cuz of magical 
> treatment of $@.

The first one works because the return-value from the eval is undef if the 
block fails.  The second one is because $@ is true if it failed, and false 
if it succeeded.

> I gather that ';' is unneeded in p6, and given that $! is the 
> 'exception'al topicalizer,
> is this construct no longer reliant on the last value in the eval block ?

I would imagine that you would do it this way:

try {
        ...
        CATCH { }
}

Only inside the CATCH does $! topicalize; I believe $_ becomes aliased to 
that.  Remember, C<try> is Perl 6's eval{}.

> put another way, does the 'topicalizer' reflect the exit condition of 
> the closure ?

It represents the exception that was thrown, and whatsoever might be 
contained in that exception.


Or am I wrong?

Luke

Reply via email to