On Mon, 17 May 2010 16:38:49 -0400, Larry Luther
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.
Larry
Yes, ref
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
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 ove
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
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. Othe
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
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 languages
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 e
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;
}
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)
{
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)
{
T
That would be great.
Thanks again
On Mon, 26 Apr 2010 18:07:22 -0400, Dan 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 an issue brought up dur
Dan:
> are opAdd, opNeg, opAddAssign etc going to be deprecated?
Yes, we can't keep two different ways, one is already complex enough.
Bye,
bearophile
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 ho
On Sat, 24 Apr 2010 05:07:41 -0400, Dan 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 == "-=")
{
mixin("x "
-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
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
{
flo
18 matches
Mail list logo