Re: Passing array as const slows down code?

2012-04-28 Thread Joseph Rushton Wakeling
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 determination in the type system to see if two parameters alias the same data

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 compile

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 com

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 a

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 left,

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

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 http:

Re: mysql binding/wrapper?

2012-04-28 Thread Adam D. Ruppe
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; nothing super fancy, but it gets the job done for me. I didn't really document it... but the

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) t

Re: mysql binding/wrapper?

2012-04-28 Thread simendsjo
On Sat, 28 Apr 2012 17:54:49 +0200, Adam D. Ruppe 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; nothing super fancy, but it gets

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 though,

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 TD

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 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 the PHP, Javascript, how

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 std.algorithm.ends

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: Hacking on Phobos

2012-04-28 Thread David Nadlinger
On Saturday, 28 April 2012 at 18:46:16 UTC, Sergey Matveychuk wrote: 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 […] The

Re: [OT] functional programming resources ?

2012-04-28 Thread SomeDude
On Friday, 27 April 2012 at 20:52:28 UTC, Mariusz Gliwiński wrote: Hello, could You recommend me some books / materials explaining different concepts in functional programming from *practical point of view*? Most preferably not requiring me to understand Haskell or other classical functional l

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

2012-04-28 Thread SomeDude
On Saturday, 28 April 2012 at 19:06:27 UTC, Jesse Phillips wrote: 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 bo

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 > 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

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 compl

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 ca