std.xml validity checking is absurd

Ali Çehreli acehreli at yahoo.com
Fri Feb 8 08:11:14 PST 2013


On 02/08/2013 04:54 AM, Andrei Alexandrescu wrote:

 >> If I write an "sqrt" function, and document it as "Please, only give me
 >> positive numbers", and then write a contract for it, and then compile my
 >> lib in release, the caller will have no way of "signing" my contract.
 >
 > I don't think std.math.sqrt should validate its input using a contract.

As the module writer, I don't know whether my function is going to be 
used as an "API function" or as an "internal function" in somebody 
else's module.

In the former case, I would like my checks to be enforce() calls so that 
I don't produce incorrect results.

However, in the latter case, I would like my checks to be in an 'in' 
block so that when my client compiles in release mode, my checks would 
disappear. This is under the assumption that my client has tested their 
code and they are sure that all of the contracts are met. There is no 
need for them to waste time running the checks unnecessarily.

Ali



More information about the Digitalmars-d mailing list