Re: Scope of 'alias'
On Friday, 14 May 2021 at 14:03:17 UTC, DLearner wrote: So 'alias' only valid from definition to end-of-function, rather than whole function? Best regards Yes. This applies to all definitions inside a function, not just aliases.
Scope of 'alias'
>>> void foo(pint p1) { alias pint=uint; import std.stdio; writeln("p1 = ", p1); } void main() { alias pint=uint; pint var1; var1 = 7; foo(var1); } <<< Does not compile. But the rather similar: alias pint=uint; void foo(pint p1) { import std.stdio; writeln("p1 = ", p1); } void main() { pint var1; var1 = 7; foo(var1); } <<< Is fine. So 'alias' only valid from definition to end-of-function, rather than whole function? Best regards