Re: Implicit die in CATCH blocks

2009-09-22 Thread Patrick R. Michaud
On Sat, Sep 19, 2009 at 06:35:45PM -0400, Kodi Arfer wrote:
 In the process of writing some more tests for CATCH blocks, I've noticed  
 what appears to be a contradiction between Synopsis 4 on the one hand  
 and pugs/t/spec/S04-statements/try.t and Rakudo's current behavior on  
 the other. 

The short answer is that Rakudo's implementation of exceptions doesn't
match the specification yet.  We still have quite a bit of work to do
there.

Pm


Implicit die in CATCH blocks

2009-09-19 Thread Kodi Arfer
In the process of writing some more tests for CATCH blocks, I've noticed 
what appears to be a contradiction between Synopsis 4 on the one hand 
and pugs/t/spec/S04-statements/try.t and Rakudo's current behavior on 
the other. The specification says there is an implicit Cdie $! just 
inside the end of the CCATCH block, and that if you want to catch an 
exception you haven't explicitly smart-matched, you need to use a 
Cdefault block. But look at this test:


{
# try with a catch
my $caught;
try {
die blah;

CATCH { $caught = 1 }
};

ok($caught, exception caught);
};

The blah ought to be rethrown by the CATCH block, avoiding the ok() 
entirely, but instead, Rakudo passes this test. Is this a mistake on the 
part of the test and the implementation, or on the part of the 
specification? It confuses matters that CATCH is defined to act like a 
switch statement, and


given EXPR { default { ... } }

is the same as

given EXPR { ... }

, making Cdefault strictly redundant in given blocks but not 
(according to the spec) CATCH blocks.