On 2012-10-26 23:56, Jonathan M Davis wrote:

Yes. It lowers to a try-catch block, but that's effectively an implementation
detail. As it stands, technically speaking, a compiler could probably
implement it without any lowering whatsoever (I don't think that the spec says
anything about how it's implemented). But even if the compiler has to use
lowering, the main problem with your suggestion is that in complicates how
scope statements work, since then it's only going to be run if the exception
type being caught matches what was being thrown, whereas right now
scope(failure) statements run on all exceptions regardless. And scope
statements aren't really meant for exception handling. Rather, they're
intended for providing a clean means of making code exception-safe. So, I
suspect that what you suggest would be rejected, but I don't know. You can
certainly create an enhancement request for it if you want to:

What about allowing catch-statements without a try-statement, something like this:

void foo ()
{
    // some code ...

    catch (Exception e)
    {

    }
}

This would be the same as the whole function would be wrapped in a try-statement. It's a quite handy feature that's available in Ruby.

--
/Jacob Carlborg

Reply via email to