Re: Operators overloading in D2

2010-05-17 Thread Larry Luther
Hi, Dan used the following method for his vector class: void opOpAssign (string op:+=)(ref Vector3 other) {...} Why the ref? As I understand it, objects of class vector would already be passed as references. Larry

Re: Operators overloading in D2

2010-05-17 Thread Steven Schveighoffer
On Mon, 17 May 2010 16:38:49 -0400, Larry Luther larry.lut...@dolby.com wrote: Hi, Dan used the following method for his vector class: void opOpAssign (string op:+=)(ref Vector3 other) {...} Why the ref? As I understand it, objects of class vector would already be passed as references.

Re: Operators overloading in D2 again

2010-05-03 Thread Dan
Hi, it certainly helps. However I can't help myself, I still thinking that this is the most complicated, hard read and to understand way to overload operators. Maybe there is something I'm missing but I can't really see the reason of all that. Other languages adopts a much easier approach, for

Re: Operators overloading in D2 again

2010-05-03 Thread Pelle
On 05/03/2010 04:28 PM, Dan wrote: Hi, it certainly helps. However I can't help myself, I still thinking that this is the most complicated, hard read and to understand way to overload operators. Maybe there is something I'm missing but I can't really see the reason of all that. Other

Re: Operators overloading in D2 again

2010-05-03 Thread Lars T. Kyllingstad
On Mon, 03 May 2010 16:46:41 +, Lars T. Kyllingstad wrote: [...] Pair opBinary(string op)(Pair p) { auto r = this; r.opOpAssign!op(p); Sorry, that last line should be: r.opOpAssign!(op~=)(p); -Lars

Re: Operators overloading in D2 again

2010-05-03 Thread Lars T. Kyllingstad
On Mon, 03 May 2010 14:28:20 +, Dan wrote: it certainly helps. However I can't help myself, I still thinking that this is the most complicated, hard read and to understand way to overload operators. Maybe there is something I'm missing but I can't really see the reason of all that. Other

Re: Operators overloading in D2 again

2010-05-03 Thread Dan
I'm still really sceptic, especially because they look to me inconsistent to each other. for example opBinary(string op:something here)(Object other) and then ther is opCmp(Obejct other) which is not template and there is only one for all these operators = = Did I understand correctly? if I

Re: Operators overloading in D2 again

2010-05-03 Thread bearophile
Dan: I'm still really sceptic, especially because they look to me inconsistent to each other. Yes, they seem divided in two groups, with different level of complexity, etc. This is true, and I think this is by design, opCmp and opEquals and few others are useful in many classes. While

Operators overloading in D2 again

2010-05-02 Thread Dan
Hi everyone, is there anyway to do this with operators overloading? : class Tester { double x = 0.0; double opBinary(string op:+)(double value) { return x+value; } Tester opBinary(string op:+)(Tester other) {

Re: Operators overloading in D2 again

2010-05-02 Thread Ali Çehreli
Dan wrote: Hi everyone, is there anyway to do this with operators overloading? : class Tester { double x = 0.0; double opBinary(string op:+)(double value) { return x+value; } Tester opBinary(string op:+)(Tester other) {

Re: Operators overloading in D2 again

2010-05-02 Thread Robert Clipsham
On 02/05/10 07:14, Dan wrote: Hi everyone, is there anyway to do this with operators overloading? : The following code does it: class Tester { double x = 0.0; T opBinary(string op:+, T)(T value) if(is(T : double)) { return x+value; }

Re: Operators overloading in D2

2010-05-01 Thread Dan
That would be great. Thanks again

Re: Operators overloading in D2

2010-04-27 Thread Steven Schveighoffer
On Mon, 26 Apr 2010 18:07:22 -0400, Dan daniele.ni...@gmail.com wrote: Thanks guys, it's more clear now. Just another question: are opAdd, opNeg, opAddAssign etc going to be deprecated? The reason is very very stupid: If I use them the documentation output is much more readable :) This is

Re: Operators overloading in D2

2010-04-26 Thread Dan
Thanks guys, it's more clear now. Just another question: are opAdd, opNeg, opAddAssign etc going to be deprecated? The reason is very very stupid: If I use them the documentation output is much more readable :) I know is stupid, but a good documentation is important. Thanks again, I really

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