Operator overloading through UFCS doesn't work

Timon Gehr timon.gehr at gmx.ch
Wed Oct 17 04:00:06 PDT 2012


On 10/16/2012 05:57 PM, Maxim Fomin wrote:
> ...
>
> At NG discussion it may look nice to define some type and then add
> operator overloading methods

Operator overloading is not magic, so your statement can be shortened to

... and then add methods

Which is still not correct, because that is not what UFCS does.


> but as soon as you import some other
> modules, authors of which also consider UFCS operators a good idea,

Who has stated that? It just does not make sense to explicitly ban
them, as they are not special.

> everything breaks including namespace conflict

The usual disambiguation procedures apply. (Which are broken in DMD at
the moment, because module-scope private symbols can cause conflicts.)

Infix operators are not special. It is just notation.

> as well as loosing
> ability to manipulate that type within built-in expression as well.

I did not get that.


More information about the Digitalmars-d-learn mailing list