UFCS idea

Dmitry Olshansky dmitry.olsh at gmail.com
Wed Jun 8 14:20:29 PDT 2011


On 09.06.2011 0:48, Timon Gehr wrote:
>> Dmitry Olshansky wrote:
>> On 09.06.2011 0:39, Timon Gehr wrote:
>>> Dmitry Olshansky wrote:
>>>> what was so bad about having 'this' inside parameters?
>>>> I thought it was rather compelling:
>>>>
>>>> void func(Type1 this, Type2 p2);
>>>> which is legal only as a free function and inside structs/classes it's
>>> declaration syntax error.
>>>> [3,2,5,3].cycle.stride(2).take(10); //and no snails :)
>>> Furthermore, it should be illegal to make UFCS clash with a method's name in order
>>> to prevent hijacking.
>> Me thinks it should be counted as another overload, and be resolved in
>> the same way - partial ordering, and report ambiguity if can't choose
>> one. Less special casing.
>>> Timon
> 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



More information about the Digitalmars-d mailing list