On Monday, 23 February 2015 at 12:30:55 UTC, Russel Winder wrote:
On Mon, 2015-02-23 at 19:50 +1000, Manu via Digitalmars-d wrote:
O[…]
This is going to sound really stupid... but do people actually
use
exceptions regularly?
I've never used one. When I encounter code that does, I just
find it
really annoying to debug. I've never 'gotten' exceptions. I'm
not sure
why error codes are insufficient, other than the obvious fact
that
they hog the one sacred return value.
D is just a whisker short of practical multiple-return-values.
If we
cracked that, we could use alternative (superior?) error state
return
mechanisms. I'd be really into that.
[…]
Return codes for value returning functions only work if the
function
returns a pair, the return value and the error code: it is
generally
impossible to work with return values that serve the purpose of
return
value and error code. C got this fairly wrong, Go gets it
fairly right.
You wouldn't need new syntax (though I think multiple returns
would be a nice addition), I think you can compile try/catch
exception syntax into error codes internally.