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

deadalnix deadalnix at gmail.com
Tue Feb 21 07:45:32 PST 2012


Le 21/02/2012 11:55, deadalnix a écrit :
> 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.

I come up with a sample code with the transient case. What do you think ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: condition.d
Type: text/x-dsrc
Size: 1836 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120221/f121789e/attachment.d>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.d
Type: text/x-dsrc
Size: 399 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20120221/f121789e/attachment-0001.d>


More information about the Digitalmars-d mailing list