assume, assert, enforce, @safe
Jonathan M Davis via Digitalmars-d
digitalmars-d at puremagic.com
Sat Aug 2 19:27:15 PDT 2014
On Saturday, 2 August 2014 at 09:46:57 UTC, Marc Schütz wrote:
> On Friday, 1 August 2014 at 21:50:59 UTC, Jonathan M Davis
> wrote:
>> And why is that a problem? By definition, if an assertion
>> fails, your code is in an invalid state,
>
> Only in an ideal world. In practice, the condition in the
> assertion could itself be incorrect. It could be a leftover
> after a refactoring, for instance.
Then it's a bug, and bugs make programs do wrong and invalid
things. I certainly don't see any reason to not optimize based on
assertions just in case someone screwed up their assertion any
more than I see a reason to avoid optimizing based on something
that's wrong in normal code.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list