On 11/18/10 12:08 PM, Jens Mueller wrote:
What I'd even like better (because contracts are release specific):
release {
     const currentWidth = width;
     const currentHeight = height;
     scope (exit) {
         assert(currentWidth == width);
         assert(currentHeight == height);
     }
}
But that does not work. Why do we have special syntax for debug but not for
release. Both seem to me very similar. In the end I tend to think
release/debug as a shorthand for version(release/debug). But that's not
quite right. Somehow it's allowed to write version(unittest) {}
equivalently for unittest {}. But for debug/release there is no such
thing. Why this asymmetry?

Jens

I think it's just for pragmatic reasons (avoid allocating a keyword for something you can do a different way). Also, it's more often that you want to insert extra code in debug builds. It's odd that you don't want the checks in debug mode, for example.

Release-only code can be inserted with:

debug {} else {
   ...
}


Andrei

Reply via email to