Will uniform function call syntax apply to operator overloads?

Tomek Sowiński just at ask.me
Tue Oct 12 15:40:07 PDT 2010


Simen kjaeraas napisał:

> Peter Alexander <peter.alexander.au at gmail.com> wrote:
> 
>> In short, when UFC is working on all types, will this be possible:
>>
>> Foo opBinary(string op)(Foo a, Foo b)
>> {
>>      return ...;
>> }
>>
>> Foo x, y;
>> Foo z = x + y;
>>
>> My reasoning here is that x + y is supposedly sugar for
>> x.opBinary!("+")(y), so the free opBinary defined above could be chosen
>> as a pseudo member of Foo.
>>
>> Will this be possible?
> 
> As long as operator overloading is defined the way it is, it should work
> like that, yes.

Funny. I remember asking this not too long ago and got no as an answer. :)
Could someone from the D team take a stance on this?

-- 
Tomek


More information about the Digitalmars-d mailing list