UFCS idea

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Jun 8 14:48:58 PDT 2011


On 09.06.2011 1:41, Alex_Dovhal wrote:
> "Dmitry Olshansky"<dmitry.olsh at gmail.com>  ???????/???????? ? ????????
> ?????????: news:isopbg$1l5d$1 at digitalmars.com...
>>> How does that prevent hijacking? If you want it to overload against
>>> members of the
>>> same name, you would have to introduce another overload set, not just
>>> another
>>> overload. (But indeed, that would be more consistent.)
>>>
>> Ehm, right in fact it seems that the function needs to participate in two
>> overload sets:
>> first is used when it's called as member function,  the set consists of
>> all UFCS functions&  member functions with the same name.
>> second is used when it's called as free function, the set consists of all
>> UFCS functions&  free functions with the same name.
>>
>> -- 
>> Dmitry Olshansky
>>
>>
> Yes, but imagine you have a situation:
> someLib.d:
> class A{
>      void member1(int a);
>      void member2(int a);
>      ...
> }
>
> someUserCode.d:
> void member3(A this, int a); //local user func
> ....
> member3(x, 1); //hundred times in user code
>
> And later library writer adds void member3(int a) member to class A.
> Now user code has name collision.
>
well, and compiler tells him about ambiguity and for a good reason.
Since UFCS is exactly to allow it to behave like a method isn't it?
It's not like UFCS will solve this kind of problem staying what it is.


-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list