Why exceptions for error handling is so important

Martin Nowak via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 12 06:57:19 PST 2015

On Monday, 12 January 2015 at 00:51:25 UTC, Walter Bright wrote:
> On 1/11/2015 5:06 AM, Dicebot wrote:
>> What is your opinion of approach advertised by various 
>> functional languages and
>> now also Rust? Where you return error code packed with actual 
>> data and can't
>> access data without visiting error code too, compiler simply 
>> won't allow it.
> 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

The general solution in functional programming is error chaining.
An example, C is a function that reads in lines of a program and 
B is a function that takes all those lines and counts words.
C will either return an error or lines and B will either 
immediately return that error to A or convert the lines to word 
This works especially well with function chaining, because you 
can hide the error propagation in a generic chaining method 
(called map).


More information about the Digitalmars-d mailing list