On Monday, 26 June 2017 at 21:53:57 UTC, John Colvin wrote:
On Sunday, 25 June 2017 at 17:38:14 UTC, mckoder wrote:
I am disappointed that D doesn't have checked exceptions.

I wonder what could be done with something like this:

void foo(int a)
{
    if (a > 0)
        throw new BlahException("blah");
    throw new BloopException("bloop");
}

unittest
{
    // NEW FEATURE HERE
    alias Exceptions = __traits(thrownTypes, foo);
}

I'm imagining one could use that to do quite a lot of what checked exceptions provide.

Yes, that would be a D idiomatic implementation of the function exception set I mentioned [1].

[1] http://forum.dlang.org/post/[email protected]

Reply via email to