www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - label idenifers: doc v. compiler

reply =?UTF-8?B?VGhvbWFzIEvDvGhuZQ==?= <thomas-dloop kuehne.cn> writes:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

http://digitalmars.com/d/statement.html#label
 Labels are in a name space independent of declarations, variables,
 types, etc. Even so, labels cannot have the same name as *local*
 declarations.
Is a *local* declaration the opposite of an imported declaration? "debug" isn't a *local* declaration, thus the following code is - according to my reading of the docs - legal, whereas the compiler rejects it: void test(){ debug: int dummy; goto debug; } This seems a bid odd and could a source for hard to track bugs. Maybe all keywords from http://digitalmars.com/d/lex.html#keyword should be disallowed as label identifiers? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDI02q3w+/yD4P9tIRArHIAJ9JPmQj4J6xTiFBNWefsgCABzk/lwCgh6MA 4tvyoTs2iGvH7RfDHIXV/VY= =iJhe -----END PGP SIGNATURE-----
Sep 10 2005
next sibling parent Hasan Aljudy <hasan.aljudy gmail.com> writes:
Thomas Kühne wrote:
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 http://digitalmars.com/d/statement.html#label
 
Labels are in a name space independent of declarations, variables,
types, etc. Even so, labels cannot have the same name as *local*
declarations.
Is a *local* declaration the opposite of an imported declaration? "debug" isn't a *local* declaration, thus the following code is - according to my reading of the docs - legal, whereas the compiler rejects it: void test(){ debug: int dummy; goto debug; } This seems a bid odd and could a source for hard to track bugs. Maybe all keywords from http://digitalmars.com/d/lex.html#keyword should be disallowed as label identifiers? Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFDI02q3w+/yD4P9tIRArHIAJ9JPmQj4J6xTiFBNWefsgCABzk/lwCgh6MA 4tvyoTs2iGvH7RfDHIXV/VY= =iJhe -----END PGP SIGNATURE-----
Isn't it always implied that keywords cannot be used for purposes other than what they are meant for?
Sep 10 2005
prev sibling parent "Walter Bright" <newshound digitalmars.com> writes:
Keywords can't be declarations, labels, etc.
Sep 10 2005