Re: ^^ implementation [Was: Re: Code speed]

2010-04-14 Thread Justin Spahr-Summers
On Wed, 14 Apr 2010 05:58:55 -0400, bearophile wrote: > > Don: > > >Raising to a float power is really a niche feature.< > > Used it as x^^0.5 to perform the square root is not a niche feature, square > roots are common enough. > And sqrt is an intrinsic, it doesn't need all std.math. I thin

Re: Code speed

2010-04-14 Thread bearophile
Robert Clipsham Wrote: > this way if/when > tango is ported to D2 it doesn't have to hack around this to allow it to > allow users to use ^^. I hope Tango2 will be designed to be installed beside Phobos2, and not in place of it. Bye, bearophile

Re: Code speed

2010-04-14 Thread Robert Clipsham
On 14/04/10 20:54, Don wrote: I have a vague recollection that correctly-rounded pow() will require bigint (can't quite remember, though). I'm also concerned about build tools -- I don't want them to have to know about the dependency. As a bare minimum, the error message will need to improve (wit

Re: Memory leak with dynamic array

2010-04-14 Thread bearophile
I'm catching up with the posts. Joseph Wakeling: > As for iteration, I don't know to what degree D's foreach() across > arrays compares to for() commands in C++ -- I guess it should be pretty > close in performance, no? As you have seen from my benchmarks, when with dmd you use: foreach (x; arr)

Re: Code speed

2010-04-14 Thread Don
Lars T. Kyllingstad wrote: Lars T. Kyllingstad wrote: Don wrote: Lars T. Kyllingstad wrote: Don wrote: bearophile wrote: So far I've just given a light reading of the code. Notes: - pow(x, 2) and sqrt(y) can be written as x ^^ 2 and y ^^ 0.5 (but you have to import std.math anyway, becaus

Re: Code speed

2010-04-14 Thread bearophile
> - the two nested loops in the main are more efficient as ref double, > this is something dmd will need to fix; A test shows that on ldc the two nested loops are a little faster without the ref. I'd like the compiler to use a "const ref" with the foreach iterates on array items bigger than a wo

Re: Code speed

2010-04-14 Thread Lars T. Kyllingstad
Lars T. Kyllingstad wrote: Don wrote: Lars T. Kyllingstad wrote: Don wrote: bearophile wrote: So far I've just given a light reading of the code. Notes: - pow(x, 2) and sqrt(y) can be written as x ^^ 2 and y ^^ 0.5 (but you have to import std.math anyway, because of a bug). That's not a

Re: Code speed

2010-04-14 Thread Lars T. Kyllingstad
Don wrote: Lars T. Kyllingstad wrote: Don wrote: bearophile wrote: So far I've just given a light reading of the code. Notes: - pow(x, 2) and sqrt(y) can be written as x ^^ 2 and y ^^ 0.5 (but you have to import std.math anyway, because of a bug). That's not a bug. It's intentional. x ^^

Re: ^^ implementation [Was: Re: Code speed]

2010-04-14 Thread Don
bearophile wrote: Don: Thank you for your answer and comments. Because pow() for floating point, when implemented properly, is a HUGE function, that ends up dragging almost all of std.math into the executable. And I think it's deceptive to do that silently. To make it completely built-in, basi

^^ implementation [Was: Re: Code speed]

2010-04-14 Thread bearophile
Don: Thank you for your answer and comments. > Because pow() for floating point, when implemented properly, is a HUGE > function, that ends up dragging almost all of std.math into the > executable. And I think it's deceptive to do that silently. > To make it completely built-in, basically all of

Re: Code speed

2010-04-14 Thread bearophile
Don: > That's not a bug. It's intentional. x ^^ y will probably always require > import std.math, if y is a floating point number. What's the rationale behind this decision? I have filed it as a bug many days ago, because I think it's a wrong intention: http://d.puremagic.com/issues/show_bug.cgi

Re: Code speed

2010-04-14 Thread Don
Lars T. Kyllingstad wrote: Don wrote: bearophile wrote: So far I've just given a light reading of the code. Notes: - pow(x, 2) and sqrt(y) can be written as x ^^ 2 and y ^^ 0.5 (but you have to import std.math anyway, because of a bug). That's not a bug. It's intentional. x ^^ y will proba

Re: Code speed

2010-04-14 Thread Lars T. Kyllingstad
Don wrote: bearophile wrote: So far I've just given a light reading of the code. Notes: - pow(x, 2) and sqrt(y) can be written as x ^^ 2 and y ^^ 0.5 (but you have to import std.math anyway, because of a bug). That's not a bug. It's intentional. x ^^ y will probably always require import s

Re: Code speed

2010-04-14 Thread Don
bearophile wrote: So far I've just given a light reading of the code. Notes: - pow(x, 2) and sqrt(y) can be written as x ^^ 2 and y ^^ 0.5 (but you have to import std.math anyway, because of a bug). That's not a bug. It's intentional. x ^^ y will probably always require import std.math, if