assume, assert, enforce, @safe

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 31 11:58:06 PDT 2014


On 7/31/2014 4:28 AM, David Bregman wrote:
> Sigh. Of course you can assume the condition after a runtime check has been
> inserted. You just showed that
>
> assert(x); assume(x);
>
> is semantically equivalent to
> assert(x);
>
> as long as the runtime check is not elided. (no -release)

No. I showed that you cannot have an assert without the assume. That makes them 
equivalent that direction.

For the other direction, adding in a runtime check for an assume is going to be 
expected of an implementation. And, in fact, since the runtime check won't 
change the semantics if the assume is correct, they are equivalent.

I.e. for practical purposes, they are the same thing. You can't have one without 
the other.


> The code generated by one will be different than the code generated by the
> other, that is because they are functionally different. This is really
> indisputable..

Oh, I dispute it very much!


> But you still want to assert to become assume in release mode? How
> will you handle the safety issue?

I don't know yet.


> So what?

It came up in the thread about assume vs assert. I assumed (!) it mattered to you.



More information about the Digitalmars-d mailing list