checkedint call removal

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 30 17:17:00 PDT 2014


Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> On 7/30/14, 7:55 AM, Tofu Ninja wrote:
>> On Wednesday, 30 July 2014 at 14:51:34 UTC, Andrei Alexandrescu wrote:
>>> Also, it's unclear to me what the optimizer would be supposed to do if
>>> an assumption turns out to be false.
>> 
>> Bad... bad... things...
> 
> So then I see nothing that assume can do that assert can't. -- Andrei

The point is that optimizations based on asserts can have a big impact
because they are leaky.

By having both, a dangerous assume and a mre harmless assert (that
terminates in debug and does nothing in release), the programmer can use
assert a lot without many consequences if there's an error. Only if
optimizations are really necessary he can use assume, but he can use it
with care.

It's not that assert is not powerful enough. It too dangerous to be used
frequently.

Tobi


More information about the Digitalmars-d mailing list