Re: How to eliminate this global variable, silent?
- From: James Kuyper <jameskuyper@xxxxxxxxxxx>
- Date: Fri, 18 Apr 2008 11:04:29 GMT
Joe Wright wrote:
jameskuyper@xxxxxxxxxxx wrote:....
Section 6.4.2.1p1 specifies, with great precision, what an identifier
is:
_identifier_:
_identifier-nondigit_
_identifier identifier-nondigit_
_identifier digit_
_identifier-nondigit_:
_nondigit_
_universal-character-name_
other implementation-defined characters
_nondigit_: one of
_ a b c d e f g h i j k l m
n o p q r s t u v w x y z
A B C D E F G H I J K L M
N O P Q R S T U V W X Y Z
_digit_: one of
0 1 2 3 4 5 6 7 8 9
Paragraph 3 explains the "other implementation-defined characters":
"An implementation may allow multibyte characters that are not part of
the basic source character set to
appear in identifiers; which characters and their correspondence to
universal character names is implementation-defined."
The characters '[' and ']' do not meet the requirements for qualifying
as either "digits" or "non-digits". Since they are part of the basic
source character set, they also can't qualify under the 'other'
category. Therefore they cannot appear anywhere in an identifier.
The C standard describes a[2] as a postfix-expression consisting of
the identifier "a", which parses as a postfix-expression in it's own
right, the subscript operator consisting of the tokens "[" and "]",
and the integer literal "2" which parses as an expression in this
context. See 6.5.2p1:
_postfix-expression_:
...
_postfix-expression_ [ _expression_ ]
Damn, this is a tough room. I now concede a[2] an expression, not an identifier. But it is an object of type int and a variable. Right?
I agree that it is an object; it is a sub-object of the aggregate object referred to by 'a'. However, my understanding is that a variable is a named object, i.e. one that can be identified using just an identifier. Therefore, I don't agree that it is a variable.
However, I see that user92300 has recently cited ISO/IEC 11404 (unfortunately, not the relevant standard) which defines the term "variable", in a way that's incompatible with my understanding. I'm preparing myself for the possibility that the relevant standard (ISO/IEC 2382) has a similar definition. If so, then you're right on both counts.
.
- References:
- How to eliminate this global variable, silent?
- From: istillshine
- Re: How to eliminate this global variable, silent?
- From: ymuntyan
- Re: How to eliminate this global variable, silent?
- From: Richard Tobin
- Re: How to eliminate this global variable, silent?
- From: ymuntyan
- Re: How to eliminate this global variable, silent?
- From: Joe Wright
- Re: How to eliminate this global variable, silent?
- From: Chris Dollin
- Re: How to eliminate this global variable, silent?
- From: Keith Thompson
- Re: How to eliminate this global variable, silent?
- From: Joe Wright
- Re: How to eliminate this global variable, silent?
- From: jameskuyper
- Re: How to eliminate this global variable, silent?
- From: Joe Wright
- How to eliminate this global variable, silent?
- Prev by Date: Re: how to specify power of number
- Next by Date: Re: pointer to string
- Previous by thread: Re: How to eliminate this global variable, silent?
- Next by thread: Re: How to eliminate this global variable, silent?
- Index(es):
Relevant Pages
|