Regular Templates May Be `mixin`d?

surlymoor surlymoor at cock.li
Sun Oct 3 02:52:20 UTC 2021


```d
// Modified sixth example from 
https://dlang.org/spec/template-mixin.html

int y = 3;

template Foo()
{
     int abc() { return y; }
}

void main()
{
     int y = 8;
     mixin Foo; // local y is picked up, not global y
     assert(abc() == 8);
}
```
This compiles and works. I checked the spec, and I don't see 
anything; probably missed it, however; mentioning the fact that 
regular templates may be used with `mixin`. Is this expected?


More information about the Digitalmars-d-learn mailing list