Static operator overloads are possible why?

Giles Bathgate gilesbathgate at gmail.com
Thu Jul 5 02:57:13 PDT 2007


> You can access static class members through variables which are of that 
> class's type.  This applies to all static methods and fields; static 
> operator overloads are no exception.  I'm not entirely sure why you can do 
> this; it's probably "the way C++ does it."


I don't know what you mean by this I tried

public class Test
{
    public char[] Name;

    public Test opAddAssign(Test value)
    {
        writefln(value.Name);
        writefln(Test.Name);
        //...
    }
}

It didnt work

> That being said, I'm not sure why you decided to try a static overload 
> instead of just new'ing t.  Another solution would be to make your multicast 
> delegate a struct type instead, which wouldn't have to be new'ed; I think 
> DFL (very .Net like form library for D) does this. 

DFL huh? there is another thing that went under the radar... Its a shame there is no "distribution" of D

Anyway I am not looking for a solution to the problem of how to create a multicast delegate class in D I am trying to solve the meta problem, of how to access an lvalue in a static operator overload.



More information about the Digitalmars-d mailing list