Names and scope in D

Dibyendu Majumdar mobile at majumdar.org.uk
Sat Nov 28 13:44:31 UTC 2020


On Saturday, 14 November 2020 at 17:54:17 UTC, Paul Backus wrote:

>
> Yes, exactly. Symbols in an inner scope are (mostly) allowed to 
> shadow symbols in an outer scope.
>
> The one exception is that local variables are not allowed to 
> shadow parameters:
>
> void fun(int x)
> {
>     int x; // error
> }

Not only parameters, it seems that inside a function, a name 
cannot be re-declared in  any inner scope.


More information about the Digitalmars-d mailing list