Re: unittests and templates

2010-05-11 Thread Steven Schveighoffer
On Tue, 11 May 2010 16:06:31 -0400, Steven Schveighoffer wrote: The ugly solution is to use static if like so: static if(isIntegral!V) { unittest { } } But that is, well, ugly. I found a less ugly solution -- remove the braces: static if(isIntegral!V) unittest { ... } Th

unittests and templates

2010-05-11 Thread Steven Schveighoffer
A cool thing I learned on the way to d2. unittests can be templatized just like the classes/structs they reside in. When enhancing dcollections with lots of detailed unit tests, I was doing things like this: class ArrayList(V) { V take() {...} unittest { auto al = new ArrayL

Re: std.complex

2010-05-11 Thread eles
== Quote from Lars T. Kyllingstad (pub...@kyllingen.nospamnet)'s article > On Tue, 11 May 2010 15:08:07 +, eles wrote: > > Maybe I am wrong, but my feeling is that if the complex numbers were a > > native type (like creal&co. are now), then it would have been possible > > to have a dedicated fo

Re: std.complex

2010-05-11 Thread Lars T. Kyllingstad
On Tue, 11 May 2010 15:08:07 +, eles wrote: > Maybe I am wrong, but my feeling is that if the complex numbers were a > native type (like creal&co. are now), then it would have been possible > to have a dedicated formatting (just like %f, %d and %s are) for > writefln. > > Putting the type int

Re: std.complex

2010-05-11 Thread eles
Maybe I am wrong, but my feeling is that if the complex numbers were a native type (like creal&co. are now), then it would have been possible to have a dedicated formatting (just like %f, %d and %s are) for writefln. Putting the type into the library seems to forbid some very nice things: - init

Re: opAddAssign still works

2010-05-11 Thread Jesse Phillips
bearophile wrote: > Pelle: >> Not yet, it's not. To compile something that's deprecated, you will need >> the -d switch. > > That's for user code marked with 'deprecated': > http://www.digitalmars.com/d/2.0/attribute.html#deprecated > I don't think it is designed to work with compiler/language fe

Re: opAddAssign still works

2010-05-11 Thread Steven Schveighoffer
On Tue, 11 May 2010 09:14:37 -0400, Simen kjaeraas wrote: Steven Schveighoffer wrote: But this function never gets called. I found out recently that template functions are not allowed in interfaces, which makes it impossible to use the new operator overloads on interfaces. The proble

Re: opAddAssign still works

2010-05-11 Thread Simen kjaeraas
Steven Schveighoffer wrote: But this function never gets called. I found out recently that template functions are not allowed in interfaces, which makes it impossible to use the new operator overloads on interfaces. The problem is however, that template functions can't be virtual, and thu

Re: opAddAssign still works

2010-05-11 Thread Steven Schveighoffer
On Tue, 11 May 2010 08:52:47 -0400, Trass3r wrote: I found out recently that template functions are not allowed in interfaces, which makes it impossible to use the new operator overloads on interfaces. Wow that should find its way into bugzilla. Already there :) http://d.puremagic.com/i

Re: std.complex

2010-05-11 Thread Lars T. Kyllingstad
On Tue, 11 May 2010 11:51:34 +, eles wrote: > the following test case also works: > > Compiling > > import std.stdio; > import std.complex; > > Complex!(double) x,y; > > int main(){ > writefln("salut!\n"); > x.re=1; > x.im=1; > y=x.conj(); > writefln("x=%f+%f*

Re: opAddAssign still works

2010-05-11 Thread Trass3r
> I found out recently that template > functions are not allowed in interfaces, which makes it impossible to use > the new operator overloads on interfaces. Wow that should find its way into bugzilla.

Re: std.complex

2010-05-11 Thread eles
the following test case also works: Compiling import std.stdio; import std.complex; Complex!(double) x,y; int main(){ writefln("salut!\n"); x.re=1; x.im=1; y=x.conj(); writefln("x=%f+%f*i\n",x.re,x.im); writefln("y=%f+%f*i\n",y.re,y.im); r

Re: std.complex

2010-05-11 Thread eles
Confirmation: in the new beta, the test case for the std.complex compiles on windows xp with dmd 2.046beta. I cannot post on the D.phobos newsgroup, but I post the confirmation here. I did not test it further. Compiling import std.complex; int main(){ return 0; } results in: C:\dmd2>

Re: opAddAssign still works

2010-05-11 Thread Steven Schveighoffer
On Mon, 10 May 2010 19:38:53 -0400, Trass3r wrote: Yeah it still works for compatibility reasons but is deprecated. Yeah, but should the old method override the new one? I assumed one nice thing about "backwards compatibility" is you could do something like this: T opOpAssign(string op)(

Re: opAddAssign still works

2010-05-11 Thread bearophile
Pelle: > Not yet, it's not. To compile something that's deprecated, you will need > the -d switch. That's for user code marked with 'deprecated': http://www.digitalmars.com/d/2.0/attribute.html#deprecated I don't think it is designed to work with compiler/language features too. The D1 compiler h

Re: opAddAssign still works

2010-05-11 Thread Pelle
On 05/11/2010 01:38 AM, Trass3r wrote: Yeah it still works for compatibility reasons but is deprecated. Not yet, it's not. To compile something that's deprecated, you will need the -d switch. Right now, both are allowed, but the old one is scheduled for deprecation and presumably later remo