Operator overloading through UFCS doesn't work

Tommi tommitissari at hotmail.com
Sat Oct 13 09:39:40 PDT 2012


On Saturday, 13 October 2012 at 16:02:25 UTC, Maxim Fomin wrote:
> From my point of view operator overloading methods are
> special functions and not treating them as candidates for
> UFCS does make more sense.

I can think of only one thing that makes custom operator methods 
"special" or different from regular methods. It's the fact that 
you don't *have* to call them through the normal method 
invocation syntax: var.opSomething(...), but rather, the language 
provides this nice layer of syntactic sugar through which you 
*can* call those methods, if you so choose to.

What you're saying is, that calling those operator methods 
through this layer of syntactic sugar, e.g. var + 3, is somehow 
fundamentally different from directly calling the method, to 
which this layer of syntactic sugar would forward the expression 
to call anyway, i.e. var.opBinary!"+"(3)


More information about the Digitalmars-d-learn mailing list