On Tuesday, 29 July 2014 at 10:13:45 UTC, Dicebot wrote:
This is one of problems. When writing library function you
don't exactly know if input is going to be user input. Use
enforces - and it won't be possible to optimize away redundant
checks. Use assertions and issue may slip uncaught.
I have taken to using versions and enforce for this. Something
like:
version(noChecks){} else
{
version = checks;
}
void foo(int a)
{
version(checks) enforce(a > 0);
// do work
}
so the user of the library has to explicitly disable the checks
when compiling the library, independent of -release. Also, all
functions should document their input assumptions.
Binary libraries is a bit different though, I guess you have to
distribute 3 versions: debug, release and release-noChecks