Making preconditions better specified and faster

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Fri Dec 16 13:36:17 PST 2016


Am Thu, 15 Dec 2016 13:48:22 -0500
schrieb Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org>:

> https://issues.dlang.org/show_bug.cgi?id=16975

Here is what I understood. While currently a contract that has
a failing assert would be treated differently from one that
throws an exception, in the future all kinds of errors would
make it return false instead of true.
What's not explicitly mentioned is what happens from there on,
but I assume that 'false' leads to some handler function in
druntime being invoked?
Also when you write that unrecoverable errors "cannot be the
case" in contracts, what do you mean by that?
A) Consider all contracts to have no side-effects. In case of
'false' return, throw a ContractFailedException and continue
execution in the caller.
B) That was meant to read "may not be the case". A failed
assert would cause the contract to return 'false', while an
Exception would be propagated to the outside. The former is
unrecoverable, the latter is recoverable. (Note: That
contradicts what I understood above.)
C) Something else. (I bet that's the correct answer.)

-- 
Marco



More information about the Digitalmars-d mailing list