Towards a better conceptual model of exceptions (Was: Re: The Right Approach to Exceptions)

deadalnix deadalnix at gmail.com
Tue Feb 21 02:55:59 PST 2012


First great post. Don't be sorry, it is insightful. The Condition 
catgory make a lot of sense to me.

Le 21/02/2012 09:15, H. S. Teoh a écrit :
> Currently, I'm still unsure whether Conditions and Exceptions should be
> unified, or they should be kept separate; deadalnix recommended they be
> kept separate, but I'd like to open it for discussion.
>

I think we could reconciliate the 2 worlds. Condition may provide 
@property Exception exception() so you can get the Exception. 
Eventually, the Condition can return itself so it is the Exception.

This Exception can be used by the handler to get information about the 
problem more specifically (if required). The Exception can also be used 
to throw it, if no handler is provided, or if the handler decide it is 
the right thing to do.

I suggested this mecanism should be implemented into std.condition and 
still think this is the way to go. Addition to the language itself 
should be as limited as possible (ie only occur if the compiler can take 
advantage of this, for example to optimize, or if this isn't 
implementable using the current state of the language).

This mecanism is not intended to replace Exception, but to provide a 
more convenient, higher level (and probably more performant) than the 
Exception mecanism. We fail back to Exceptions if this mecanism fail.


More information about the Digitalmars-d mailing list