The Right Approach to Exceptions

Jacob Carlborg doob at me.com
Mon Feb 20 00:57:55 PST 2012


On 2012-02-19 23:44, Jonathan M Davis wrote:
> 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

Oh, as in template constrains, I see. Forgot about that.

> catch(Ex1, Ex2 : Ex0 e)
>
> would be even more consistent though for the reasons that you point out.
>
> - Jonathan m Davs

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list