assert and enforce both compiled out with -release

Ali Çehreli acehreli at yahoo.com
Sat Jan 27 14:51:23 UTC 2018


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.

Ali


More information about the Digitalmars-d-learn mailing list