Referring to alias parameters in a mixin template

anonymous via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Dec 17 11:56:32 PST 2014


On Wednesday, 17 December 2014 at 15:40:25 UTC, aldanor wrote:
> On Wednesday, 17 December 2014 at 12:49:10 UTC, anonymous wrote:
[...]
>> As to if there were `T` or `func` in the target scope, they'd 
>> be
>> shadowed by the template parameters, no matter if there's a
>> string mixin or not.
> That makes sense. So if I understand correctly, basically after 
> each string mixin it has to check if any new symbols were 
> leaked into the current scope and then try to resolve them, if 
> any,

Well, every mixed-in string necessarily goes through a full
compiler pass. I don't think there's anything special going on
with regards to new symbols.

> with template parameters taking precedence over local 
> variables? (This obviously has to repeat in case of nested 
> mixins)

My wording was bad. There's no shadowing. When a template is
mixed in, the substitution of parameters happens before the
injection. That means, when the parameters are substituted there
are no local symbols yet. And when the code is injected there are
no parameters any more. So local symbols and parameters are never
considered at the same time. Obviously, parameters take
precedence, simply because they're considered earlier. But
there's no shadowing.

Disclaimer: I'm not a compiler dev. I don't know if/how all this
is specified (or I'd quote/link it). I'm just describing current
compiler behaviour and how it makes sense to me.


More information about the Digitalmars-d-learn mailing list