The Right Approach to Exceptions

Andrei Alexandrescu SeeWebsiteForEmail at
Sun Feb 19 07:58:40 PST 2012

On 2/19/12 3:26 AM, Jonathan M Davis wrote:
> On Sunday, February 19, 2012 19:00:20 Daniel Murphy wrote:
>> I wasn't really serious about implicit fallthrough.
> Lately, it seems like I can never tell whether anyone's being serious or not
> online. :)
>> Out of the syntaxes I could come up with:
>> catch(Ex1, Ex2 e)
>> catch(e : Ex1, Ex2)
>> catch(Ex1 | Ex2 e) // java 7 syntax, horrible
>> I like (e : list) the best.  Naturally it would also accept a type tuple of
>> exceptions.
> LOL. Personally, I actually think that the Java 7 syntax looks great (I'd
> never seen it before), but catch(e : Ex1, Ex2) is just as good and more
> consistent with the language as a whole, since it doesn't try to give any
> operators a new meaning (as Java's does).
> - Jonathan M Davis

The Java7 syntax looks meaningful to me, too - you want to catch the 
union type. A possibility that wouldn't change the language for us would 
be to catch Algebraic!(Ex1, Ex2).


More information about the Digitalmars-d mailing list