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

deadalnix deadalnix at
Tue Feb 21 09:24:01 PST 2012

Le 21/02/2012 18:10, H. S. Teoh a écrit :
> On Tue, Feb 21, 2012 at 06:01:09PM +0100, deadalnix wrote:
>> Le 21/02/2012 17:56, H. S. Teoh a écrit :
>>> The only thing I added, perhaps, is that instead of problem-specific
>>> conditions, as they appear to have in Lisp, I'm looking at generic
>>> categories of conditions, that you can handle from high-level code
>>> without ever needing to know the specifics of exactly what the condition
>>> is, and yet have the low-level code work it all out once you've made a
>>> decision.
>> About this, I did some sketching, and I think LISP guys may have
>> outsmarted you.
>> Let's consider a transiant condition. You can retry or give up and
>> throw. But, if you want to retry or not often depend on what went
>> wrong, no ?
> True, and there's nothing to stop you from digging into the details of
> the raised Condition if you want to. I did consider implementing
> Conditions as some kind of class hierarchy, so that the generic
> categories are at the top, underneath Condition, then actual specific
> Conditions can extend them. If your handler knows of a specific
> Condition, then you can access any pertinent additional info, and make
> decisions based on that.
> But what I wanted to know was, can you still do something meaningful
> even if you knew nothing beyond the top-level generic categories of
> Conditions? That way, your handler will still work with new Conditions
> that you've never seen before.
> T

And here come an idea of mine :

If the Condition has a way to provide the Exception associated. So you 
can get the hierarchy from the Exception, and you don't need to creat 
two hierachy of classes just for the bloat.

You'll fond attached some sketching code. What do you think of it ?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.d
Type: text/x-dsrc
Size: 378 bytes
Desc: not available
URL: <>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: condition.d
Type: text/x-dsrc
Size: 2264 bytes
Desc: not available
URL: <>

More information about the Digitalmars-d mailing list