Operators overloading in D2

2010-04-24 Thread Dan
Hi All, I just downloaded D2 after a friend of mine told me about it and I was playing with it, just to get confident with the language. In order to do that I was converting a simple geometric Vector3 class I wrote in c++. this is the (relavant for this post) D code class Vector3 {

Re: Operators overloading in D2

2010-04-24 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dan wrote: Hi All, So there's my questions Why D2 changed in this way the operators overloading? I saw the the compiler compiles both the functions, even considering this I assume it's not safe to use the old D1 way, right? Because Walter got

Re: Newsgroups, off-topic

2010-04-24 Thread Joseph Wakeling
Steven Schveighoffer wrote: I did a little review of the code, I concur that the code is pretty identical, and the D version does not really do any extra allocation. I found one place where you were using pow(x, 2) to square something in the D version but doing it with simple multiplication

Re: Newsgroups, off-topic

2010-04-24 Thread Steven Schveighoffer
On Sat, 24 Apr 2010 05:32:25 -0400, Joseph Wakeling joseph.wakel...@webdrake.net wrote: Steven Schveighoffer wrote: I did a little review of the code, I concur that the code is pretty identical, and the D version does not really do any extra allocation. I found one place where you were

Re: Operators overloading in D2

2010-04-24 Thread Steven Schveighoffer
On Sat, 24 Apr 2010 05:07:41 -0400, Dan daniele.ni...@gmail.com wrote: So there's my questions Why D2 changed in this way the operators overloading? To avoid repeating tons of boilerplate code. For example, you can do this: void opOpAssign(string op)(ref Vector3 other) if (op == += || op ==

Arrays of many different (sub)classes

2010-04-24 Thread Joseph Wakeling
Hello all, Occasionally in C++ I find it useful to build an array which contains classes of multiple different types all using the same interface -- by constructing an array of pointers to some common base class, e.g. class BaseClass { // blah, blah ... }; class A : BaseClass { // ...

Re: Arrays of many different (sub)classes

2010-04-24 Thread Robert Clipsham
On 24/04/10 20:06, Joseph Wakeling wrote: Hello all, Occasionally in C++ I find it useful to build an array which contains classes of multiple different types all using the same interface -- by constructing an array of pointers to some common base class, e.g. class BaseClass { // blah,