assume, assert, enforce, @safe
David Bregman via Digitalmars-d
digitalmars-d at puremagic.com
Thu Jul 31 00:40:13 PDT 2014
On Wednesday, 30 July 2014 at 22:01:23 UTC, Walter Bright wrote:
> I'd like to sum up my position and intent on all this.
>
> 1. I can discern no useful, practical difference between the
> notions of assume and assert.
People have explained the difference repeatedly, a ridiculous
number of times now. Could you please take a minute to understand
it this time instead of flippantly dismissing it again?
assert does a runtime check, assume does not
assume affects code generation/optimization, assert does not
assert is for debugging, assume is not
assume is for optimization, assert is not
In terms of what they practically do, they have *nothing* in
common, their functions are entirely orthogonal.
Still think there is no practical difference?
> 2. The compiler can make use of assert expressions to improve
> optimization, even in -release mode.
This will introduce a lot of undefined behavior, including making
@safe code with asserts unsafe. I really think this needs to be
acknowledged. As far as I can tell from the other thread, it
still hasn't been.
More information about the Digitalmars-d
mailing list