On Saturday, 2 August 2014 at 05:07:58 UTC, Chris Cain wrote:
On Saturday, 2 August 2014 at 04:40:53 UTC, Tofu Ninja wrote:
His claim is that an assertion is a claim by the person
asserting. That claim has not been proven to be true or false.
Meaning that as a claim, the compiler can't do anything with that information alone. The compiler can try to check if the claim is true and if it is, use that information to optimize. But if it is
not checked it is merely a claim with no backing, and as such,
nothing can be done with it.

Of course, I can understand that interpretation. But at the same time, why would you write something and expect a compiler to do nothing with it?

But he _does_ want the compiler to do something: check whether it's true (or more precisely: check whether it's not false in this particular case). He wants it to be exactly equivalent to:

    version(assert)
    if(!(condition))
        throw new AssertError(...);

Now, you could ask: Why use `assert` instead of writing it like this? Well, for one, it's more concise, and secondly, it shows that your intention is to check the semantic validity of your program, and not just do an arbitrary check that is part of your algorithm.

Reply via email to