On Saturday, 14 August 2021 at 04:01:31 UTC, Mike Parker wrote:
On Saturday, 14 August 2021 at 03:47:05 UTC, Tejas wrote:
```d
import std;
auto abc(T)(auto ref T a, auto ref T b){
return a+b;
}
auto def(T)(auto ref T a, auto ref T b){
return a*b;
}
alias macro_1 = abc;
void main()
{
writeln(macro_1(15, 20));
alias macro_1 = def;// is this NOT considered variable
shadowing?
writeln(macro_1(100, 20));
}
```
Shadowing local symbols is illegal. But it's okay for local
symbols to have the same name as module-scope symbols. You can
disambigbuate with [the module scope operator][1]:
```d
void main()
macro_1(); // the local symbol
.macro_1(); // the external symbol
}
```
[1]: https://dlang.org/spec/module.html#module_scope_operators
Oh right, the ```.``` operator will reference variable in the
_module_ scope, not just the _immediate outer scope_, that's why
it is not considered shadowing in that case.
Thank you very much!