Thread overview | |||||
---|---|---|---|---|---|
|
October 24, 2005 Entity name shadowing: valid or not ? | ||||
---|---|---|---|---|
| ||||
Is entity (aka symbol?) name shadowing valid or not in D?
In statement.html the spec says:
"A block statement introduces a new scope for local symbols. A local symbol's name, however, must be unique within the function.
...
void func2(){
int x;
{
int x; // illegal, x is multiply defined in function scope
}
}
"
However that same code segment compiles quite ok. Also, in mixin.html, the first example uses name shadowing to illustrate the use of mixins.
--
Bruno Medeiros - CS/E student
"Certain aspects of D are a pathway to many abilities some consider to be... unnatural."
|
October 26, 2005 Re: Entity name shadowing: valid or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bruno Medeiros | Bruno Medeiros wrote: > Is entity (aka symbol?) name shadowing valid or not in D? > In statement.html the spec says: > "A block statement introduces a new scope for local symbols. A local symbol's name, however, must be unique within the function. > > ... > > void func2(){ > > int x; > { > int x; // illegal, x is multiply defined in function scope > } > } > " > > However that same code segment compiles quite ok. -> digitalmars.D.bugs > Also, in mixin.html, the first example uses name shadowing to illustrate the use of mixins. Yes, if mixins are an exception to this rule, then it should be documented. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:- C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++>++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
October 29, 2005 Re: Entity name shadowing: valid or not ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Stewart Gordon | Stewart Gordon wrote: > Bruno Medeiros wrote: > >> Is entity (aka symbol?) name shadowing valid or not in D? >> In statement.html the spec says: >> "A block statement introduces a new scope for local symbols. A local symbol's name, however, must be unique within the function. >> >> ... >> >> void func2(){ >> >> int x; >> { >> int x; // illegal, x is multiply defined in function scope >> } >> } >> " >> >> However that same code segment compiles quite ok. > > > -> digitalmars.D.bugs > >> Also, in mixin.html, the first example uses name shadowing to illustrate the use of mixins. > > > Yes, if mixins are an exception to this rule, then it should be documented. > > Stewart. > Well, but is it a rule or is it not? I'd still like to hear from Walter about it. -- Bruno Medeiros - CS/E student "Certain aspects of D are a pathway to many abilities some consider to be... unnatural." |
Copyright © 1999-2021 by the D Language Foundation