Why exceptions for error handling is so important

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Mon Jan 12 13:41:48 PST 2015


On 1/12/15 1:35 PM, bearophile wrote:
> Walter Bright:
>
>> Yes, it still appears to be just a wrapper around returning two
>> values, and that has to be done for everything.
>
> There's lot of functional theory behind such ideas.
>
>
>> There's another downside to returning two values - extra code is
>> generated, and it consumes another register. It allocates very scarce
>> resources to rare cases - not a recipe for high performance.
>
> I suggest to start inverting your point of view: try to look why the
> F#/Haskell way of managing errors is good in those languages...
>
> In bugzilla I asked for a "maybeTo" that is similar to the "to" Phobos
> function, but it's @nogc nothrow because it returns an Nullable!T result.

I can't believe I agree with everything bearophile just said :o). -- Andrei


More information about the Digitalmars-d mailing list