Why exceptions for error handling is so important

Tobias Pankrath via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 12 03:24:37 PST 2015


On Monday, 12 January 2015 at 11:09:01 UTC, Walter Bright wrote:
> On 1/12/2015 3:02 AM, Tobias Pankrath wrote:
>> As far as I understand is, it requires each component to 
>> settle on the same
>> discriminated union that packs the error and result, which he 
>> calles Result but
>> is usually Choice in F#.
>>
>> Now in D we use the opDot to chain components, which works 
>> since we have UFCS.
>> In F# there a simply three different opDots: >>, >>= and >=> 
>> which take care of
>> the adaption.
>
> Or we could just use exceptions, which require none of that.

Well, yes. I don't think though, that either exception or 
"railway" requires more boilerplate than the other. They just 
offer different strength.

The plus side for railway (as compared D exceptions): Easier 
comprehension of control flow and scope(exit) and scope(failure) 
are not needed anymore. Using something like this in @nogc 
functions seems easier than making exceptions work by 
preallocating them.

Haven't programmed anything of value in F# though.


More information about the Digitalmars-d mailing list