You know how I was saying in my DConf talk...

Ethan gooberman at gmail.com
Wed Jul 24 03:11:02 UTC 2019


On Wednesday, 24 July 2019 at 03:01:33 UTC, Adam D. Ruppe wrote:
> Those are by design and it is a fairly useful design too. The 
> presence of a name in the outer scope overrides the same name 
> from the mixin. This allows easy selective customizing of a 
> mixin template as you use it.

https://dlang.org/spec/template-mixin.html

3. Unlike a template instantiation, a template mixin's body is 
evaluated within the scope where the mixin appears, not where the 
template declaration is defined. It is analogous to cutting and 
pasting the body of the template into the location of the mixin 
into a nested scope. It is useful for injecting parameterized 
‘boilerplate’ code, as well as for creating templated nested 
functions, which is not possible with template instantiations.

So which one is it? Is it copy/paste and a replacement for 
parameterised C macros as sold, or is it something else?

The spec here reeks of following the implementation instead of 
being clearly thought out.

And it's far from the first time I've made this point.


More information about the Digitalmars-d mailing list