Operator overloading through UFCS doesn't work

Maxim Fomin maxim at maxim-fomin.ru
Wed Oct 17 04:32:25 PDT 2012


On Wednesday, 17 October 2012 at 11:00:05 UTC, Timon Gehr wrote:
> 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.
>

It is not correct as long as you cavil at lexis, however the 
statement has room for correction.

>> 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.

Who stated that they should be "explicitly banned"? I explained 
potential problem in previous posts.

>> 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.

Again, the problem is in conflict between different declared 
operator overloading functions across different modules.


More information about the Digitalmars-d-learn mailing list