UFCS idea

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Jun 8 15:07:02 PDT 2011


On 09.06.2011 1:55, Timon Gehr wrote:
> Alex Dovhal wrote:
>> 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.
> No, his 100 calls are all unambiguous.
>
That, if we do rewrite in one direction only:
e.g. x.member3(1) --> member3(x, 1);
but it would be an unpleasant surprise in this case, suppose his 101th 
call looked like:
x.member3(1)
then after change it suddenly stops calling his code, and calls library 
code. And silently!
So I think UFCS should work in both directions.

-- 
Dmitry Olshansky



More information about the Digitalmars-d mailing list