www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: against enforce

reply Kagamin <spam here.lot> writes:
I can't think of an occasion when I would want to have my uses of 
enforce() stripped for a release build.

Ideally enforce shouldn't have side effects, so its removal shouldn't affect your business logic.
Removing asserts once I am sure 
that my code has no logic errors make sense

Did you ever have this sense? Well, I can be sure "hello world" has no bugs, but for something more complex... only if you're a programming god, but even then your way won't suit us mortals.
Performance is irrelevant if you are processing corrupted memory or 
malformed input.

I believe, sometimes it's easier to make sure that the input is correct, than to make sure the code has no bugs.
This means that libraries (should) have 2 types of assert, 
but I hesitate to suggest the creation of a synonym to help better 
document the difference between them, as I find that the use of in{} and 
out{} do a pretty good job of that already.

So you suggest to check iota's input in contract? They say, phobos is compiled with -release flag, so all contracts are removed. Is it ok for D programmers?
Mar 25 2011
parent bearophile <bearophileHUGS lyco.com> writes:
Kagamin:

 They say, phobos is compiled with -release flag, so all contracts are removed.

I presume this problem will be fixed "soon", probably with two versions of Phobos in the standard distribution. Otherwise D contract programming loses a significant part of its meaning and usefulness. Bye, bearophile
Mar 25 2011