On Wednesday, April 8, 2015 at 6:10:07 AM UTC+10, Toivo Henningsson wrote:
>
> I agree, seems only consistent that try without a catch should catch 
> nothing.


There are four combinations of the current syntax

1. try end
2. try catch end
3. try finally end
4. try catch finally end

but there are more than four possible behaviours when an exception occurs

1. propagate the exception
2. ignore the exception
3. catch the exception (then it doesn't exist)
4. propagate the exception running a finally
5. ignore the exception running a finally
6. catch the exception (then it doesn't exist) then run a finally

so some behaviours have to miss out :)

1. is pretty pointless inside a try block since it behaves as if its not 
there, so its not provided with a syntax, catch the exception and re-throw 
it if you really want to

5. is the other one to miss out on its own syntax, in general its probably 
the right decision because (empirically) its the least used and can be 
provided using try catch finally end

So the behaviours that do not have syntax are logical, but not symmetric 
with respect to finally, one is a propagate and the other is an ignore, and 
thats why the behaviour seems to be different, it is deliberately different.

Cheers
Lex


Reply via email to