digitalmars.D - Signature of opAddAssign
- Andrew Fedoniouk (10/10) Mar 02 2005 what is the proper way from D point of view?
- zwang (2/17) Mar 03 2005 IMO, I prefer the former which enables chained += operations.
- Andrew Fedoniouk (9/17) Mar 03 2005 Seems like my question was not clear enough....
- Andrew Fedoniouk (5/24) Mar 03 2005 Disregard my previous post.
what is the proper way from D point of view?
struct point
{
point opAddAssign(int i) { x += i; y += i; return make(x,y); }
// --or just --
void opAddAssign(int i) { x += i; y += i; }
}
( I am porting this into D
http://www.terrainformatica.com/org/gool/geometry.h )
Andrew.
Mar 02 2005
Andrew Fedoniouk wrote:
what is the proper way from D point of view?
struct point
{
point opAddAssign(int i) { x += i; y += i; return make(x,y); }
// --or just --
void opAddAssign(int i) { x += i; y += i; }
}
( I am porting this into D
http://www.terrainformatica.com/org/gool/geometry.h )
Andrew.
IMO, I prefer the former which enables chained += operations.
Mar 03 2005
Seems like my question was not clear enough.... Question is about compiler - what code it produces on a += b ? Compiler may suppres returning value of opAddAssign and make value by its own. And that is the question. As far as I understand there are no 'this' in struct methods (why?) so I cannot effectively return something like *this from methods. Am I right? Andrew.struct point { point opAddAssign(int i) { x += i; y += i; return make(x,y); } // --or just -- void opAddAssign(int i) { x += i; y += i; } }IMO, I prefer the former which enables chained += operations.
Mar 03 2005
Disregard my previous post. this in struct's works. Just tested it. Perfect. "Andrew Fedoniouk" <news terrainformatica.com> wrote in message news:d07d6n$1st$1 digitaldaemon.com...Seems like my question was not clear enough.... Question is about compiler - what code it produces on a += b ? Compiler may suppres returning value of opAddAssign and make value by its own. And that is the question. As far as I understand there are no 'this' in struct methods (why?) so I cannot effectively return something like *this from methods. Am I right? Andrew.struct point { point opAddAssign(int i) { x += i; y += i; return make(x,y); } // --or just -- void opAddAssign(int i) { x += i; y += i; } }IMO, I prefer the former which enables chained += operations.
Mar 03 2005








"Andrew Fedoniouk" <news terrainformatica.com>