assume, assert, enforce, @safe

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 00:42:20 PDT 2014


On 7/30/2014 6:16 PM, Dicebot wrote:
> On Wednesday, 30 July 2014 at 23:50:51 UTC, H. S. Teoh via Digitalmars-d wrote:
>> But if you don't want to check ever to be removed, currently you have to
>> write:
>>
>>     if (!requiredCondition)
>>         assert(0); // compiler never removes this
>>
>> which IMO is relatively clear, and the use of assert(0) for forceful
>> termination is consistent with existing practice in D code.
>
> Not helping.
>
> ```
> import std.stdio;
>
> void foo()
> in { writeln("in contract"); }
> body { }
>
> void main() { foo(); }
> ```
>
> Compile with -release and check the output.

What do you expect to happen?


More information about the Digitalmars-d mailing list