assert semantic change proposal

Jeremy Powers via Digitalmars-d digitalmars-d at puremagic.com
Tue Aug 5 11:59:20 PDT 2014


>
> And there will be no injection of undefined behaviour - the undefined
>> behaviour is already there if the asserted constraints are not valid.
>>
>
> Well, no. http://en.wikipedia.org/wiki/Undefined_behavior
>

Well, yes: Undefined behaviour in the sense the writer of the program has
not defined it.

A program is written with certain assumptions about the state at certain
points.  An assert can be used to explicitly state those assumptions, and
halt the program (in non-release) if the assumptions are invalid.  If the
state does not match what the assert assumes it to be, then any code
relying on that state is invalid, and what it does has no definition given
by the programmer.

(And here I've circled back to assert==assume... all because I assume what
assert means)

If the state that is being checked could actually ever be valid, then it is
not valid for an assert - use some other validation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140805/2402e5ba/attachment.html>


More information about the Digitalmars-d mailing list