assert and enforce both compiled out with -release

kdevel kdevel at vogtner.de
Sat Jan 27 18:33:36 UTC 2018


On Saturday, 27 January 2018 at 18:00:32 UTC, rjframe wrote:
> I think I see what you mean; you interpret "use asserts, 
> because enforce will be compiled out" to imply that asserts 
> wouldn't be compiled out, correct?

Is there any other meaningful interpretation?

> Since, in reality, both would be compiled out, it shouldn't 
> matter what you use, so the docs shouldn't care. That makes 
> sense.

That's precisely my point.

> The documentation seems to assume the reader has certain 
> expectations of assert and enforce[0], so each function 
> expresses a different intention to the programmer; when I see 
> `assert()` I expect those checks only in non- release mode; 
> when I see `enforce()` I expect those checks regardless of the 
> flags that have been set[1]. Placing `enforce` in a contract 
> messes with that expectation.

Right.

> What language here would make more sense to you? Anything I can 
> come up with is either awkward or pretty verbose.

I suggest the deletion of the sentence "Use assert in contracts."



More information about the Digitalmars-d-learn mailing list