On Tuesday, 6 March 2018 at 10:17:42 UTC, Walter Bright wrote:
On 3/6/2018 1:58 AM, Jonathan M Davis wrote:
[...]
The entire point of making assert a core language feature was
so that the compiler could take advantage of it to generate
better code. It's been like that for D since day 1. It has
always been documented to do that. It has been discussed many
times in this n.g. over the years with loooong threads. I
designed it that way so that D could potentially produce better
code than other languages in ways they could not match.
There is no other purpose to making it a core language feature.
It's fine if you want an assert-like feature to have other
semantics - just define one called 'check', give it the
semantics you want, and put it in the library. As I mentioned
to Timon, support for that sort of thing is why D has special
support for __LINE__ and __FILE__.
As a side node, we have a `verify()` exactly for this:
https://github.com/sociomantic-tsunami/ocean/blob/v3.x.x/src/ocean/core/Verify.d
(and because in some circumstances we need to be able to catch
programming errors in servers that are low risk to catch and just
ignore the current request and continue with our lives, with
asserts we can't do that because they throw an Error).