UFCS for struct opCall?

Jesse Phillips Jessekphillips+d at gmail.com
Mon Apr 8 20:39:42 PDT 2013


I see no issue with the request, I've never used a non-static 
opcall, seems odd, but for a uniform syntax I'd say go for it.

> - - - - - - - - - - -
>
> Regarding UFCS, currently this doesn't work, I don't know if 
> this should be considered a bug or not (I think the answer is 
> positive):
>
>
> struct Node {}
> void foo(Node* p) {}
> void main() {
>     auto p = new Node();
>     foo(p); // OK
>     p.foo;  // Error: no property 'foo' for type 'Node'
> }
>
>
> Bye,
> bearophile

D has specified that . (dot) will dereference, I don't see this 
as a bug. What do you think should happen if you do have a 
foo(Node p) {}? Now on to Some points from the BZ entry.

Jonathan, UFCS was never planned for arrays, the only reason the 
bug wasn't fixed was because it was nice and figured it should be 
expanded upon. Planning for it to only work with arrays would 
just be weird.

Andrej, The statement related to reversing foo(a) means that you 
don't get a.foo(), since bearophile is requesting this it should 
try foo(a). Also about how long we have had UFCS:
http://d.puremagic.com/issues/show_bug.cgi?id=662

This jira you reference is commented with: "UFCS for all basic 
types and enums is implemented in dmd 2.059." which was released 
in April last year. The oldest bug you mention is for the array 
"version."


More information about the Digitalmars-d mailing list