The Right Approach to Exceptions

Jonathan M Davis jmdavisProg at gmx.com
Sun Feb 19 14:44:50 PST 2012


On Sunday, February 19, 2012 16:07:27 Jacob Carlborg wrote:
> On 2012-02-19 10:26, 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.
> >> 
> >> http://d.puremagic.com/issues/show_bug.cgi?id=7540
> > 
> > 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
> 
> How is "catch(e : Ex1, Ex2)" consistent with the language? It's
> completely backwards. catch-block are written as follows:
> 
> catch (Exception e) {}
> 
> Not
> 
> catch (e : Exception) {}

I meant the meaning of  the : operator vs the meaning of the | operator. : has 
to do with derived types already, whereas | is for bitwise operations. Doing 
something like

catch(Ex1, Ex2 : Ex0 e)

would be even more consistent though for the reasons that you point out.

- Jonathan m Davs


More information about the Digitalmars-d mailing list