UFCS for D

Steven Schveighoffer schveiguy at yahoo.com
Fri Mar 30 05:13:30 PDT 2012


On Fri, 30 Mar 2012 08:10:14 -0400, deadalnix <deadalnix at gmail.com> wrote:

> I would expect this not to work, because bar isn't defined in module1  
> and template are supposed to use declaration scope, not instantiation  
> scope (unless it is mixin template).

Right, I think it's the way it works now.  But consider that the template  
instantiation *does* pull in some stuff from the instantiation scope (i.e.  
the template's module may not import the type being used to instantiate).   
I think it would be OK for the compiler to consider UFCS functions from  
the type's defining module as well, since you cannot instantiate the  
template for that particular type without having imported that module  
(i.e. it's guaranteed to instantiate the same no matter what module does  
it first).

-Steve


More information about the Digitalmars-d-announce mailing list