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: Passing array as const slows down code?

2012-04-28 Thread bearophile
Joseph Rushton Wakeling: ... because I found I got about a 2s speedup. It's exactly the speedup which was removed by adding const to the function input, so I presume it's as you say, that this was implicitly creating a local copy. I suggest to take a look at the asm in both cases, and

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: Passing array as const slows down code?

2012-04-28 Thread Joseph Rushton Wakeling
On 28/04/12 14:53, bearophile wrote: I suggest to take a look at the asm in both cases, and compare. Adding const doesn't cause local copies. I'm afraid I have no idea how to do that, or what to look for.

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

cannot cast

2012-04-28 Thread Namespace
I finished my Ref/NotNull struct, but i've got a problem: If i try to cast the class, which should implicit convert to Ref!(Type) with alias this, i get the following error message: cannot cast a1.getRef(Ref.d,72u) of type Ref!(A) to type RefTest.Ref.__unittest1.B Can someone explain that to

mysql binding/wrapper?

2012-04-28 Thread simendsjo
I guess there are several bindings lingering around. Has anyone experience with any of these? I found the following: https://github.com/britseye/mysqln https://github.com/britseye/mysqld https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/mysql.d

Re: cannot cast

2012-04-28 Thread Namespace
On Saturday, 28 April 2012 at 14:21:32 UTC, Namespace wrote: I finished my Ref/NotNull struct, but i've got a problem: If i try to cast the class, which should implicit convert to Ref!(Type) with alias this, i get the following error message: cannot cast a1.getRef(Ref.d,72u) of type Ref!(A) to

Re: mysql binding/wrapper?

2012-04-28 Thread simendsjo
On Sat, 28 Apr 2012 17:54:49 +0200, Adam D. Ruppe destructiona...@gmail.com wrote: On Saturday, 28 April 2012 at 15:30:13 UTC, simendsjo wrote: https://github.com/adamdruppe/misc-stuff-including-D-programming-language-web-stuff/blob/master/mysql.d That's mine. I use it all the time;

Should I wait for the new edition of TDPL ?

2012-04-28 Thread SomeDude
Hi all, Not owning TDPL right now, I feel I could learn the language much more quickly with it. But Andrei hinted somewhere that there would be a new edition of his book. Should I wait for it ?

Re: mysql binding/wrapper?

2012-04-28 Thread Adam D. Ruppe
On Saturday, 28 April 2012 at 16:19:37 UTC, simendsjo wrote: As it resides in this big misc repository, does it have many dependecies? It depends on the database.d module in there too. (database.d provides the base interface and some common functions with other db providers.) That's it

Re: Should I wait for the new edition of TDPL ?

2012-04-28 Thread H. S. Teoh
On Sat, Apr 28, 2012 at 06:27:52PM +0200, SomeDude wrote: Hi all, Not owning TDPL right now, I feel I could learn the language much more quickly with it. But Andrei hinted somewhere that there would be a new edition of his book. Should I wait for it ? I had known of D before I bought TDPL.

Re: Should I wait for the new edition of TDPL ?

2012-04-28 Thread simendsjo
On Sat, 28 Apr 2012 20:20:45 +0200, H. S. Teoh hst...@quickfur.ath.cx wrote: Then one day my wife made me go to a bookstore with her. While there, I offhandedly decided to look for TDPL, on the off-chance that it *might* be in the computer books section. And sure enough, I found it amid all

Re: Hacking on Phobos

2012-04-28 Thread Sergey Matveychuk
On Tuesday, 17 April 2012 at 19:28:05 UTC, Joseph Rushton Wakeling wrote: Oddly enough building rdmd with my newly-build dmd results in error: rdmd.d(197): Error: function std.path.rel2abs!().rel2abs is deprecated /usr/local/include/d2/std/algorithm.d(4226): Error: template

Re: Should I wait for the new edition of TDPL ?

2012-04-28 Thread Jesse Phillips
On Saturday, 28 April 2012 at 16:27:53 UTC, SomeDude wrote: Hi all, Not owning TDPL right now, I feel I could learn the language much more quickly with it. But Andrei hinted somewhere that there would be a new edition of his book. Should I wait for it ? Andrei mentioned it may be time for a

Re: Should I wait for the new edition of TDPL ?

2012-04-28 Thread H. S. Teoh
On Sat, Apr 28, 2012 at 08:23:54PM +0200, simendsjo wrote: On Sat, 28 Apr 2012 20:20:45 +0200, H. S. Teoh hst...@quickfur.ath.cx wrote: Then one day my wife made me go to a bookstore with her. While there, I offhandedly decided to look for TDPL, on the off-chance that it *might* be in the

Re: Passing array as const slows down code?

2012-04-28 Thread Jonathan M Davis
On Saturday, April 28, 2012 13:17:36 Joseph Rushton Wakeling wrote: On 27/04/12 20:26, Steven Schveighoffer wrote: No, it can't. There can easily be another non-const reference to the same data. Pure functions can make more assumptions, based on the types, but it would be a very complex

alias this : cast turns into endless loop

2012-04-28 Thread Namespace
Trying with U opCast(U : Object)() { return new U(); } work fine. It isn't a solution, but i don't understand why this works and the following not: U opCast(U : Object)() { return cast(U) this._obj; } I hope really some of you