The state of string interpolation
Neia Neutuladh
neia at ikeran.org
Thu Dec 6 21:08:40 UTC 2018
On Thu, 06 Dec 2018 20:49:08 +0000, Paul Backus wrote:
> Mixin templates can *add* symbols to the caller's scope, but they can't
> refer to *existing* symbols unless they're passed in as template
> parameters.
A mixin template is declared as `mixin template Foo() {}`. This form of
template can refer to symbols in the instantiating scope. For instance:
mixin template Foo()
{
auto b = a;
}
void main()
{
int a = 12;
mixin Foo;
writeln(b);
}
All templates can be mixed in, but if it wasn't declared as `mixin
template`, it only has access to symbols in the declaration scope.
More information about the Digitalmars-d
mailing list