Feature request: assert expressions should live inside version(assert)
Tommi
tommitissari at hotmail.com
Sun Jul 7 06:42:51 PDT 2013
On Sunday, 7 July 2013 at 13:12:06 UTC, Tommi wrote:
> But would it be possible to implement it something like:
> [..]
Although, I don't know if the best possible behaviour is to
silently compile the following assert out of existence in release
mode:
version (assert)
{
enum cond = false;
}
void main()
{
assert(cond);
}
A better behaviour probably would be to spew a warning message
asking the user if he's sure he knows what he's doing.
Then, yet another solution (a code breaking one) would be to make
it so that only literally saying:
assert(0);
or
assert(false);
or
assert(null);
...would exhibit that special assert behaviour.
Anything else would be semantically runtime-evaluated and no
other forms of assert would remain in release builds. For
example, this kind of an assert would be compiled out of
existence in release mode:
enum bool cond = false;
assert(cond);
More information about the Digitalmars-d
mailing list