Static operator overloads are possible why?

Giles Bathgate gilesbathgate at gmail.com
Sat Jun 30 02:31:11 PDT 2007


Bill Baxter Wrote:

> Just a couple of quick comments about your post:
> 1) It looks like you're reinventing std.signals.

Its irrelavent how i got to the example scenario, but thanks for the tip I wasn't aware of std.signals.

> 2) The usual operator for adding another handler onto a list is ~= 
> (opCatAssign) not +=.

Ok fair point. but the same issue exists

consider the following code:

public class Test
{
	public char[] Name;

	public static Test opCatAssign(Test value)
	{
		writefln(value.Name);
		writefln("Where is t?");
	}
}

int main()
{

	Test t;
	Test b = new Test();
	b.Name = "foo";

	t ~= b;
}

t ~= b;     Translates to     This.opCatAssign(b);

Where does t go?



More information about the Digitalmars-d mailing list