Why no contracts for release build?
Dicebot via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 3 07:39:36 PDT 2014
Contracts are not supposed to be use for error checking / input
validation. Quoting docs for enforce: "Also, do not use enforce
inside of contracts (i.e. inside of in and out blocks and
invariants), because they will be compiled out when compiling
with -release. Use assert in contracts. "
Contracts are supposed to verify that there are no fundamental
flaws in internal logic of the program which will immediately pop
up in test / debug runs. This may imply very expensive sanity
checks that are not welcome in release builds for performance
reasons.
In your case you should simply move `enforce` to the function
body and remove contract.
More information about the Digitalmars-d
mailing list