DMD 1.035 and 2.019 releases

Pablo Ripolles in-call at gmx.net
Thu Sep 4 14:20:53 PDT 2008


Walter Bright Wrote:

> Pablo Ripolles wrote:
> > little typo: writefln("f(%1$s) = %2$%", x, y);      --->
> > writefln("f(%1$s) = %2$s", x, y);
> > 
> > it doesn't compile anyway!
> > 
> > Walter, don't you think that the ctor overloading should be on
> > "static opCall" better than *any* opCall?
> 
> That would make opCall overload unlike anything else.

Ok, sorry again, I didn't mean overloading, I did mean *override* or substitute as there is no inheritance for the structs.  does it change your answer?

Walter, please, correct me where I'm wrong.

* ctors are somehow static operations (UML parlance), they construct the instance when the struct identifier is invoked with the corresponding arguments through the "()" operator.

* static ctors, being the keyword "static" not an "Attribute" but a "StorageClass" (in D parlance), are something different.

* static member functions, being the keyword "static" an "Attribute" (in D parlance), are static operations (UML parlance) as they don't need an instance to be invoked on.

* opCall is the member function that is invoked when the calling-function-operator "()" is applied to an instance as if it were a function

* static opCall is the static member function that is invoked when the calling-function-operator "()" is applied to a struct identifier as if it were a function.

Hence, since there is a clear connection between the first point and the last point, why should the ctor substitute (or *override* as it has been used by you before) other than the static opCall mentioned in the last point?

My experiments with real code and the last compiler version show that once there is present a ctor it even invalidates the possibility of accessing the *non-static* opCall to use a plain instance of that struct as if it were a function.  Is that the expected behavior?

I would understand if that the preference would take place between the ctor and the static opCall (both use the same syntactic expression on the struct), but I sincerely don't see the symmetry when the preference takes place between the ctor and the non-static opCall.

Thanks!



More information about the Digitalmars-d-announce mailing list