digitalmars.D.learn - Scope of 'alias'
- DLearner (30/31) May 14 2021 >>>
- Paul Backus (3/6) May 14 2021 Yes. This applies to all definitions inside a function, not just
>>> 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
May 14 2021
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 regardsYes. This applies to all definitions inside a function, not just aliases.
May 14 2021