Hello all,

I've just been reading through this page: http://dlang.org/version.html

Is there a way to put in place a conditional segment of code that is included if the code is _not_ compiled with the -release flag?

Of course I can put in a debug statement, but that would require me to compile with -debug. I'd like the opposite, that unless I explicitly specify the code as release-ready, the specified set of checks will be performed.

The reason I'm asking is because the checks I want to perform are of the form,

    foreach(x; myVeryLargeArray) {
        assert(/* ... some condition about x */);
    }

... and I'm concerned that with the foreach() loop in place, it will slow down the code even if the assert() statements are ignored at compile time. So I'd like to be able to do something instead like,

    version(!release)
    {
        foreach(x; myVeryLargeArray) {
            assert(/* ... some condition about x */);
        }
    }

... is this possible?

Thanks & best wishes,

    -- Joe

Reply via email to