Thread overview | |||||
---|---|---|---|---|---|
|
September 10, 2005 label idenifers: doc v. compiler | ||||
---|---|---|---|---|
| ||||
Attachments: | 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 |
September 10, 2005 Re: label idenifers: doc v. compiler | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kühne | 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?
|
September 11, 2005 Re: label idenifers: doc v. compiler | ||||
---|---|---|---|---|
| ||||
Posted in reply to Thomas Kühne | Keywords can't be declarations, labels, etc. |
Copyright © 1999-2021 by the D Language Foundation