On Mon, 03 Oct 2011 14:57:33 -0400, Andrej Mitrovic
<andrej.mitrov...@gmail.com> wrote:
Looks like I can use some D tricks for this:
import std.stdio;
struct Point
{
int x, y;
void opOpAssign(string op)(int rhs)
{
mixin ("x = x " ~ op ~ " rhs;");
mixin ("y = y " ~ op ~ " rhs;");
}
}
Probably slightly off topic, but be very careful with operator overloads
without using constraints.
For example, I can do some weird things to your struct:
Point p;
p.opOpAssign!"*x; y+="(5);
I suspect operator overloads are going to be a large hole in the interface
design of many objects, but at least they won't be exploitable once
compiled.
-Steve