Register based error-handling?
via Digitalmars-d
digitalmars-d at puremagic.com
Thu Nov 6 13:05:35 PST 2014
On Thursday, 6 November 2014 at 19:18:14 UTC, Jeremy Powers via
Digitalmars-d wrote:
> This is why checked exceptions were invented.
Yeah, I agree. Main reasons for classical exception handling:
1. Get error handling directly to a level where it can be handled
to prevent propagating clutter in the logic.
2. Make sure that the program does not continue by mistake.
3. Recovery at the failure point, by having the main call site
fix the error then go back to where the failure occurred, but
this was too complicated in practice. It is possible for floating
point exceptions though (replace the failed computation with a
value).
> Personally I prefer exceptions over error codes, as any
> sufficiently
> advanced use of error codes will start to resemble exceptions
> anyway...
Yes, it is primarily a performance vs convenience issue. You can
stuff a lot of information into 256 bits, so it is not as
restrictive as errno.
> I'd really like a language-enforced way to do this. Don't have
> any better suggestion than checked exceptions though...
I have no direct experience with checked exceptions, but it
sounds interesting. Still, the main issue with exceptions is
performance.
More information about the Digitalmars-d
mailing list