On Saturday, 27 January 2018 at 14:51:23 UTC, Ali Çehreli wrote:
On 01/27/2018 06:36 AM, kdevel wrote:
On Saturday, 27 January 2018 at 14:31:13 UTC, Ali Çehreli wrote:
> But assert is also ignored in release mode:

The documentation is not clear. "they will be compiled out" means "contracts are compiled out". So, an enforce() would disappear if it's inside such a block, which should not be what the programmer wants for an enforce().

The documentation was clear as glass (but wrong): "Use assert in contracts."

Fixed it through the "Improve this page" link on that Phobos page:

  https://github.com/dlang/phobos/blob/master/std/exception.d

"Use $(D assert) in contracts." is still in there.

What's wrong with that? What documentation is trying to say is "do not use enforce in contracts; use assert in contracts" and that's exactly the idea.

I can't see a problem which would be solved by following this advice. It distracts the reader (me) from gettin his (my) work done. If I compile not for release both, enforce and assert, are in effect. If I compile for release both, enforce and assert, are disabled. So by replacing enforce with assert I gain nothing.

Reply via email to