Am 31.07.2014 21:59, schrieb bearophile:
Daniel Gibson:

so they can make sure to use assert() accordingly.

What's the correct way to use the assert-assume hybrid?

I guess in many cases I'd avoid using assert() in fear of breaking my defensively written program (like that example from earlier: assert(x !is null); if(x) { x.foo = 42; }).

All this pretty much sounds like, if I should ever write any serious software in D in the future, I'd use assert() like assume() and I'd write my own dumbAssert() that does checks in debug mode and does nothing in release mode and is ignored by the optimizer (hopefully.. until it gets too smart again and starts evaluating debug code paths in hope of inferring something about the program state in release builds).

Actually, this somehow makes me afraid of D's design by contract stuff that will probably also be used by the optimizer in the same way..

Somehow all this assumes that you found all problems (at least the ones you check in assert()) by testing during development.. *I* personally wouldn't be so arrogant to assume that my code is bugfree just because it passed testing...

Cheers,
Daniel

Reply via email to