checkedint call removal

Tofu Ninja via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 22:49:19 PDT 2014


On Thursday, 31 July 2014 at 05:05:33 UTC, Walter Bright wrote:
> On 7/30/2014 8:09 PM, Tofu Ninja wrote:
>> When is the appropriate time to use an assert? If an assert
>> should not be used on input, then any thing that can't be
>> statically known is considered an input and anything that is
>> derived from an input is also an input... so when can we use an
>> assert? The only things left it seems are things know at 
>> compile
>> time and at that point what is the the point of having assert
>> when we have static assert...
>
> Asserts are used to verify the logic of your code is correct:
>
>    x = y + y;
>    assert(x == 2 * y);

If x and y are floats and y is nan then that assert will fail.....
That assert is implicitly verifying that the input y is not nan,
that is a misuse of assert by your definition.

Any assert made on a piece of data that is derived from inputs is
verifying some aspect of that input, which is a misuse of assert
according to the current definition. So I still state that
according to current definitions, assert should only be used on
things that are known at compile time. What is the use of that?


More information about the Digitalmars-d mailing list