digitalmars.D.learn - Entity name shadowing: valid or not ?
- Bruno Medeiros (18/18) Oct 24 2005 Is entity (aka symbol?) name shadowing valid or not in D?
- Stewart Gordon (12/31) Oct 26 2005 Yes, if mixins are an exception to this rule, then it should be document...
- Bruno Medeiros (7/38) Oct 29 2005 Well, but is it a rule or is it not? I'd still like to hear from Walter
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."
Oct 24 2005
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.bugsAlso, 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.
Oct 26 2005
Stewart Gordon wrote:Bruno Medeiros wrote: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."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.bugsAlso, 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.
Oct 29 2005