Why exceptions for error handling is so important

Tobias Pankrath via Digitalmars-d digitalmars-d at puremagic.com
Sun Jan 11 23:53:06 PST 2015


On Monday, 12 January 2015 at 00:51:25 UTC, Walter Bright wrote:
> It's a great question. I have a lot of experience with error 
> codes, and with exceptions. I have zero with the packed scheme, 
> though that doesn't stop me from having an opinion :-)
>
> Perhaps I misunderstand, but given A calls B calls C,
>
>    A => B => C
>
> and C detects an error, and A knows what to do with the error. 
> B then becomes burdened with checking for the error, invoking 
> some sort of cleanup code, and then propagating it.
>
> Wouldn't this be uglifying B's source code?
>
> With exceptions, C throws, A catches, and B's cleanup happens 
> automatically.
>
> This matters very much for pipeline style programming (i.e. 
> ranges and algorithms).

Here is one approach to it: 
http://fsharpforfunandprofit.com/posts/recipe-part2/


More information about the Digitalmars-d mailing list