On Friday, 1 August 2014 at 10:42:50 UTC, Marc Schütz wrote:
On Friday, 1 August 2014 at 09:02:36 UTC, Walter Bright wrote:
On 7/31/2014 11:24 PM, "Ola Fosheim Grøstad" <[email protected]>" wrote:
On Friday, 1 August 2014 at 02:44:51 UTC, Walter Bright wrote:
That entry makes no mention of assert being used as an optimization hint.

Saying that a predicate is always true means it's available to the optimizer.

An assert does not say that the predicate is always true.

Yes, it does. From Meyers' comprehensive tome on the topic "Object-Oriented Software Construction" (1997) where he writes:

"A run-time assertion violation is the manifestation of a bug in the software."

   -- pg. 346

In fact, Meyers calls it "rule (1)" of assertions.

No, the statement in this quote does not imply that it is always true. It says that there is a bug if it isn't, which obviously wouldn't make any sense if the predicate were always true.

An assertion doesn't tell the compiler that a predicate is true, it tells the compiler to _check whether_ it is true.

Even the WP article that you referred to says:
"An assertion may be used to verify that an assumption made by the programmer [...] remains valid"
https://en.wikipedia.org/wiki/Assertion_%28software_development%29#Assertions_for_run-time_checking

It may be used to _verify_ an assumption, not to _claim_ that it is true.

Reply via email to