UFCS idea

Timon Gehr timon.gehr at gmx.ch
Wed Jun 8 13:48:54 PDT 2011


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

Timon


More information about the Digitalmars-d mailing list