exceptions vs error codes
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jul 11 05:59:42 PDT 2016
On 7/9/16 11:02 PM, 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.
Swift does exactly this. It doesn't have exceptions, but mimics them by
passing a hidden "error" parameter that is filled in if an error occurs.
No stack unwinding occurs, just normal returns.
This allows them to get around stack unwinding issues with ARC.
I don't think this is possible for D to switch to. It would break too
much code. You have to instrument your code properly to get this
behavior, and it's actually quite unpleasant IMO.
-Steve
More information about the Digitalmars-d
mailing list