And, in fact, opDispatch doesn't do that, either.
Both of them should treat opCall like a normal member.
Comment #1 by k.hara.pg — 2012-05-17T20:35:54Z
Please give us an actual and possible reduced code. otherwise, this might become useless report.
Comment #2 by wfunction — 2012-05-17T21:34:38Z
struct C { void opCall() { } }
struct A { C c; alias c this; }
void main() { A f; f(); }
Comment #3 by wfunction — 2012-05-17T21:36:14Z
And regarding opDispatch:
struct C { void opDispatch(string op, T...)(T) { } }
void main() { C f; f(); }
Comment #4 by k.hara.pg — 2012-05-17T21:47:32Z
(In reply to comment #2)
> struct C { void opCall() { } }
> struct A { C c; alias c this; }
> void main() { A f; f(); }
Hmm, thank you. I'll try to fix the issues this weekend.
(In reply to comment #3)
> And regarding opDispatch:
>
> struct C { void opDispatch(string op, T...)(T) { } }
> void main() { C f; f(); }
I'm not sure this is valid. With current implementation, opDispatch cannot forward operator overloading like f.opDispatch!"opUnary". I think this is an enhancement issue about opDispatch feature. Creating new issue is better IMO.
Comment #5 by wfunction — 2012-05-17T22:21:32Z
Thanks.
Just wondering, why is the second one an 'enhancement'? Isn't opUnary just a member, which should also be opDispatch'ed?
(I'm figuring that the only members which should not be opDispatch'able are: opDispatch itself, the constructors, and the destructor. Anything else, by definition, is dispatched on the object.)
Comment #6 by k.hara.pg — 2012-05-17T23:04:02Z
(In reply to comment #5)
> Thanks.
>
> Just wondering, why is the second one an 'enhancement'? Isn't opUnary just a
> member, which should also be opDispatch'ed?
Today these forwarding doesn't work at all.
struct S { void opDispatch(string op, A...)(A args){} }
void main() {
S s;
+s; // not converted to opDispatch!("opUnary", ...)
s + s; // not converted to opDispatch!("opBinary", ...)
s(); // not converted to opDispatch!("opCall", ...)
}
So I think this is an enhancement rather than a bug.
> (I'm figuring that the only members which should not be opDispatch'able are:
> opDispatch itself, the constructors, and the destructor. Anything else, by
> definition, is dispatched on the object.)
I think no. At least, constructor and destructor have some special features (e.g. can modify const members for construction), but opDispatch doesn't.
Comment #7 by wfunction — 2012-05-18T00:42:50Z
(In reply to comment #6)
> Today these forwarding doesn't work at all.
lol I imagined that was the bug. I guess you could call it the lack of a feature too haha.