Operator overloading through UFCS doesn't work

Maxim Fomin maxim at maxim-fomin.ru
Mon Oct 15 01:17:26 PDT 2012


On Sunday, 14 October 2012 at 19:50:54 UTC, Artur Skawina wrote:
> On 10/14/12 08:13, Maxim Fomin wrote:
>> The only mentioned reason is to allow writing operator 
>> overloading methods outside type scope - just because somebody 
>> (currently two people) consider it logical to broaden UFCS 
>> usage.
>
> It's more than two people... Also, it's not about "broadening 
> UFCS usage", it's about making UFCS work properly.

When UFCS was added to the language its purpose was to call free 
functions pretending you are invoking methods. It does it job 
pretty well and actually works properly. But some questions 
arise: how this addition interacts with other parts of the 
language:
- with calling through pointer (8603)
- with template alias parameters (8692)
- with function imports (6185)
- with typeof operator (8661)
- with operator overloading
- ...
- probably other issues which are not encountered yet.

Each time there should be a decision to choose which language 
feature has higher priority. That is why this is broadening UFCS 
usage on areas of the language where it has never been before 
rather than making work properly in existing areas of usage.

>> This doesn't solve ay practical issue.
>
> Obviously, it does. Otherwise this issue wouldn't come up 
> repeatedly.
>
> artur

Actually not - the only purpose mentioned in the thread was to 
place operator overloading methods outside scope of declaration.


More information about the Digitalmars-d-learn mailing list