checkedint call removal

via Digitalmars-d digitalmars-d at puremagic.com
Mon Jul 28 08:20:42 PDT 2014


On Monday, 28 July 2014 at 15:07:07 UTC, Daniel Murphy wrote:
> Let's say you want to add two numbers, but instead of writing 
> 'a + b' you write 'a - b'!!!!  The program fails even though 
> you totally meant to write the correct code.

You are trolling me. :-[

Verification is not specification. D stands for DOOMED if this 
goes through.

If asserts were used as optimization constraints then the viral 
nature of this will undermine all codebases that use libraries. 
Make one frigging function call, pass through a overstated assert 
and all your precious handcrafted if-checks evaporates without 
notice. Goodbye protection against division-by-zero, NaN, 
out-of-bounds checks etc.

> I disagree.  If you do not want your assertion removed then 
> don't compile with -release.

Asserts are there to harness programs, not to weaken them.

> Where in the spec does it say assert is a tool for inserting 
> breakpoints?

It says they inject checks. Not semantic constraints. They are 
not verified.

> Asserts are a tool for conveying to the compiler certain 
> conditions that you expect to be true.

No, assert() is a tool for testing that certain constraints hold 
at RUNTIME, because you failed to prove them.





More information about the Digitalmars-d mailing list