std.xml validity checking is absurd

FG home at fgda.pl
Fri Feb 8 13:37:43 PST 2013


On 2013-02-08 18:16, Ali Çehreli wrote:
> void foo(double a, double b)
> {
>      enforce(a > b, "a must be greater than b");
>      sqrt(a - b);
> }
>
> void main()
> {}
>
> See how sqrt() is *not* on my module's API? I have already enforced that my API
> function foo() is called correctly. My call to sqrt() is an internal call of my
> module. Therefore the checks inside sqrt() should not be repeated beyond my
> testing stage.


This calls for some way to be able to call sqrt without running checks:

     sqrt(a - b);   // would run all "in" checks
     #sqrt(a - b);  // tells the compiler to bypass the "in" checks in sqrt

Sorry for inventing clumsy syntax, but you get the picture.
Naturally it won't bypass checking if sqrt is in a compiled library.


More information about the Digitalmars-d mailing list