Why exceptions for error handling is so important

deadalnix via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 13 15:58:52 PST 2015


On Tuesday, 13 January 2015 at 23:47:58 UTC, Ola Fosheim Grøstad 
wrote:
> On Tuesday, 13 January 2015 at 23:40:41 UTC, deadalnix wrote:
>>> 1. Restricting the exception object to 512 bytes, 
>>> preallocated in TLS.
>>>
>>
>> Exception can bubble from one thread to another.
>
> How? If you are thinking coroutines, then the exception can be 
> moved with it.
>

http://dlang.org/phobos/core_thread.html#.Thread.join

>>> 2. Only have one exception in flight per thread
>>>
>>
>> I don't see how you could have more.
>
> In a catch you can throw a new one and initialize with the old, 
> but if they are both in the same memory space it will go wrong.
>

When you are in the catch, you are not unwinding anymore. You 
could indeed loose chaining to be able to reuse the memory, that 
is not what is slow when it come to exception, so it won't make 
it fast.

>>> 3. Require that the first 8 bytes of the exception buffer are 
>>> 0 when no exception is in flight, and use them for encoding 
>>> exception type when one is in flight.
>>>
>>
>> The first 8 bytes are already what is used to do matching. 
>> But, because of inheritance, it is not as simple as you think 
>> it is. Also, who the fuck care what is in the buffer when no 
>> exception are in flight ?
>
> 1. So that you can mark a non-D function with @checkexception 
> and allow it to both cast D-exceptions and propagate 
> D-exceptions.
>

Empty hand waving, not not addressing the point.

>> Skipping 4 and 5, you obviously didn't though that through.
>
> ?

What you propose in point 1 - 3 is weak at best. You haven't put 
serious effort thinking about what you are proposing, so there is 
no reason anyone should spend any serious effort criticizing it.


More information about the Digitalmars-d mailing list