UFCS for D

deadalnix deadalnix at gmail.com
Sun Apr 1 23:19:23 PDT 2012


Le 31/03/2012 02:25, Walter Bright a écrit :
> On 3/30/2012 12:36 PM, Walter Bright wrote:
>> On 3/30/2012 12:11 PM, Steven Schveighoffer wrote:
>>> On Fri, 30 Mar 2012 14:27:43 -0400, Walter Bright
>>> <newshound2 at digitalmars.com>
>>> wrote:
>>>
>>>>
>>>> I would argue that:
>>>>
>>>> 3. An extension method for an argument of type template parameter T
>>>> will be
>>>> looked up only in the instantiation scope.
>>>
>>> I don't think you looked at my counter case in detail. Your idea
>>> leads to two
>>> different instantiations of tmpl!Foo having two different
>>> implementations,
>>> depending on which extension methods you include. In fact, in one
>>> place, the
>>> instantiation might succeed, but in another, the instantiation might
>>> fail.
>>
>> Yes, you're right. I missed that nuance. I don't really know how to
>> fix it.
>
> Ah, I know how to fix it. Mark such instantiations as "local" ones, so
> they are mangled with the module name of where they were instantiated from.

I think this is a terrible idea. Additionally, such a function can be 
passed as template parameter using an alias parameter, or the module to 
import can be passed.

This is a non issue. I don't see why UFCS would be treated as special in 
regard to template instantiation. Template and UFCS are orthogonal concepts.


More information about the Digitalmars-d-announce mailing list