November 28, 2020 Re: Names and scope in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dibyendu Majumdar | On Saturday, 28 November 2020 at 15:16:11 UTC, Dibyendu Majumdar wrote:
> On Saturday, 14 November 2020 at 17:06:49 UTC, Dibyendu Majumdar wrote:
>
>>
>> I couldn't find the rules that D uses to decide whether a name conflicts or not. If I missed something please can someone point me to it?
>
> module scopes;
>
> int scopes;
>
> This is accepted by the compiler which surprised me.
> Is this intentional?
The reason these do not conflict is that they are not in the same scope. `int scopes` is inside the module (FQN: scopes.scopes), whereas `module scopes` *is* the module (FQN: scopes).
|
November 29, 2020 Re: Names and scope in D | ||||
---|---|---|---|---|
| ||||
Posted in reply to Paul Backus | On Saturday, 28 November 2020 at 19:36:25 UTC, Paul Backus wrote:
> On Saturday, 28 November 2020 at 15:16:11 UTC, Dibyendu Majumdar wrote:
>>
>> module scopes;
>>
>> int scopes;
>>
>> This is accepted by the compiler which surprised me.
>> Is this intentional?
>
> The reason these do not conflict is that they are not in the same scope. `int scopes` is inside the module (FQN: scopes.scopes), whereas `module scopes` *is* the module (FQN: scopes).
Yes okay, that makes sense.
|
Copyright © 1999-2021 by the D Language Foundation