Conditional compilation for non-release version

2012-04-28 Thread Joseph Rushton Wakeling
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

Re: Conditional compilation for non-release version

2012-04-28 Thread bearophile
Joseph Rushton Wakeling: 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? Contract programming? D is designed to make it hard on purpose to do what you want to do. The reason I'm asking is because the checks

Re: Conditional compilation for non-release version

2012-04-28 Thread Timon Gehr
On 04/28/2012 02:05 PM, Joseph Rushton Wakeling wrote: 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

Re: Conditional compilation for non-release version

2012-04-28 Thread F i L
asserts aren't compiled into release builds (except assert(false)). So, if the loop only contains asserts, the compiler *should* be able to strip out the loop altogether. I don't know if DMD actually does that, though. Or you could use debug statements: debug foreach (x; largeArray) {

Re: Conditional compilation for non-release version

2012-04-28 Thread Joseph Rushton Wakeling
On 28/04/12 15:03, F i L wrote: Or you could use debug statements: Yes, that was what I wanted to avoid -- I wanted the tests to be there by default, not only when debugging ... :-) AFAICS the foreach loop probably does get optimized out by the compiler (I'm using GDC); if anything is