exceptions vs error codes

Jack Stouffer via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 9 23:59:40 PDT 2016


On Sunday, 10 July 2016 at 03:02:31 UTC, Superstar64 wrote:
> In terms of performance and code generation exceptions are 
> faster in the regular path while error codes are faster in the 
> error path.
>
> Would it be possible and a good idea to have a language feature 
> that allows some exceptions to use error code code generation.

If I understand correctly, you want C/Go style error codes when a 
function fails rather than exceptions?

This is possible, it's just not used by Phobos. Just use 
std.variant and have your function return the value on success 
and the error value on failure.


More information about the Digitalmars-d mailing list