Thread overview
[Issue 8062] UFCS and operator overloading
Feb 06, 2019
Basile-z
Mar 21, 2020
Basile-z
February 06, 2019
https://issues.dlang.org/show_bug.cgi?id=8062

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--- Comment #6 from hsteoh@quickfur.ath.cx ---
Correct me if I'm wrong, but according to spec (https://dlang.org/spec/operatoroverloading.html), operator overloading only works for member functions, not for module-level functions. So UFCS wouldn't apply in this case.

--
February 06, 2019
https://issues.dlang.org/show_bug.cgi?id=8062

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |b2.temp@gmx.com
         Resolution|---                         |INVALID

--- Comment #7 from Basile-z <b2.temp@gmx.com> ---
Yes you're right. Please OP reopen with a better example in case the operator was supposed to be a member func.

--
February 07, 2019
https://issues.dlang.org/show_bug.cgi?id=8062

--- Comment #8 from jens.k.mueller@gmx.de ---
I think my reasoning back then (almost seven years ago) was that operator overloading just rewrites one syntax into another. In the specific case a + b -> a.opBinary!("+")(b). I thought about this as a purely syntactical lowering which seems to be wrong. Because the compiler seems to actually check whether the template member function actually exists. That's why the chain seems to stop there and UFCS is not performed. Thanks for the clarification.

Back then it was interesting to me as it would have allowed me to implement operators via free functions which I would have liked. I could have even placed them in a different module. Not that you cannot get a similar behavior by passing template arguments but this seemed more involved.

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=8062

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--