Maybe D was wrong on contracts
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Sun Sep 13 20:53:20 UTC 2026
On 14/09/2026 6:32 AM, Alexandru Ermicioi wrote:
> Should be these 3: IllegalArgumentException for in contract
> IllegalStateException for invariant IllegalResultException for out contract
There is little point to doing that, due to function calls.
> for nothrow it should throw Error variants since they are uncatcheable.
> for nogc plain assert and exit, or a global shared singleton immutable
> instance is thrown.
@nogc you're on your own, no need to bake it into the language/runtime.
> But seriously, if a contract fails it's not like end of the world in
> most cases, so it should be handled by exceptions so app can decide
> whether it is possible to handle it or not, where default is ofc exit
> fast from app.
Absolutely. Most asserts should not be asserts.
And using asserts in production code like web servers are actually a
form of DOS attack of your own creation.
More information about the Digitalmars-d
mailing list