exceptions vs error codes

phant0m via Digitalmars-d digitalmars-d at puremagic.com
Sun Jul 10 10:19:31 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.

Personally, I don't understand the need for exceptions at all. 
Usually, only a calling context can fix the error and continue 
execution of the program. If exception caught by a top level 
handler, all it can do is just a crash. Moreover, with 
exceptions, you need to wrap every piece of code with ugly 
"try/catch". A plain check of the return code is much better. 
Sometimes you can't return something adequate (when an index is 
out of range or container is empty). These cases are programmer's 
errors and assert is more than enough.


More information about the Digitalmars-d mailing list