Conclusions of the exception discussion

Daniel Murphy yebblies at
Sat Feb 25 05:21:39 PST 2012

"Martin Nowak" <dawg at> wrote in message 
news:op.v98ik4hysqugbd at dawg-freebsd.lan...
>> It's currently 'catch(auto e : E1, E2, E3)' but changing the syntax is
>> trivial if everyone decides they want it.
> We should be consistent and allow to specify a type instead of auto.

That's a very good idea.

> The exception types (E1, E2, E3) should expand TypeTuples similar to how 
> you
> declare base classes.

Oops, I meant to do this and completely forgot.

> As for the syntax how about '=' assigning a catched exception.
> catch(IOException io = E1, E2, E3)
> catch(auto io = E1, E2, E3)

That syntax (sort of) already means declare variables io, E2 and E3.

> The colon is used for type conversions, where left implicitly converts to 
> right.
> catch(E1, E2, E3 : IOException io)
> catch(E1, E2, E3 : auto io)

And that looks like three template arguments, sorta...

The syntax I've implemented was 'inspired' by the base class list syntax. 
When base class protection is removed it could even use the same parsing 
function.  It's listing derived classes, not base classes, but this is the 
closest thing in D syntax I could find.
It also works with typetuples in the same way.

But anyway, I'll implement whatever gets W approval. 

More information about the Digitalmars-d mailing list