UFCS idea

Alex_Dovhal alex_dovhal at yahoo.com
Wed Jun 8 14:41:15 PDT 2011


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




More information about the Digitalmars-d mailing list