Re: Another spinoza challenge
- From: Flash Gordon <smap@xxxxxxxxxxxxxxxxx>
- Date: Tue, 25 Aug 2009 21:04:11 +0100
Dennis (Icarus) wrote:
"Flash Gordon" <smap@xxxxxxxxxxxxxxxxx> wrote in message news:6b0bm6xh9s.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxxDennis (Icarus) wrote:"Flash Gordon" <smap@xxxxxxxxxxxxxxxxx> wrote in message news:91s9m6x8mq.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxxDennis (Icarus) wrote:<snip>
All it asked was what's a valid variable name - an implementation-defined variable in a header would be valid.
It'd be unusual, but valid.
An implementation could define behaviour for this post making it valid C, so by your definition EVERY possible file is valid C since some implementation could define behaviour for it.
That's not what I said, and not sure where you're deriving that.
The point I was driving at is that a specific implementation allowing something beyond the C standard does not make a it valid beyond that implementation, so a general statement it is valid is not appropriate.
It's a variable, and the name is syntactically valid.
Yes, but that is syntactic validity rather than validity in general.
A translation unit containing only the line...
int main;
is syntactically valid. However, try writing a program for a hosted implementation where that is one of the translation units.
In any case, if a C compiler specifies behaviour for some specific construct which the C standard doesn't, it is valid for the specific compiler, not valid in general, making it perfectly reasonable to say it is not valid (or to not include it in the list of valid identifiers).
The question asked what is a valid variable name.
It is, as an implementation can have
extern int _MAX_POWER;
in a header.
Do you agree with that?
An implementaion can do
#define _MAX_POWER 32
In which case you cannot use _MAX_POWER as a variable on that implementation. Do you agree with that? If so, that shows that apart
Of course.
OK, so on such an implementation, is _MAX_POWER valid as a variable name? Just to avoid any get-out you might think of, the implementation behaves as if that #define has been provided to all translation units (which it is allowed to) and aborts compilation on any attempt to either undefine or redefine it (which it is also allowed to).
from specific implementations which document _MAX_POWER as being allowable for a variable, it is not valid, because it might lead you to having (after macro expansion
int 32;
So in general it is not valid, and that is important for a test which is not about a specific implementation.
Remember, the question simply asked about valid identifiers.
It should be pretty clear that it is, reserved for the implementation because of the leading _, but it is a valid identifier.
Yes, which make it not unambiguously valid, since it might not be valid (as in an attempt to use it as an identify might cause compilation to abort with an error).
Can you see now why a reasonable interpretation of the word "valid" would lead to consider _MAX_POWER as not being valid?
Onky if you read in more that what is being asked.
No, I think it is a perfectly reasonable interpretation of the word valid in the context of a test on C. To the point where on a non-multiple choice test where the question was...
Is _MAX_VALUE a valid identifier?
I would mark as "fail" an answer of "yes", even if the test was given to a beginner. An answer of "no" would not get full marks either, but would get some!
I've never said it is the ONLY possible interpretation, only that it is a reasonable one.
<snip>
I still say my interpretation is reasonable.
--
Flash Gordon
.
- Follow-Ups:
- Re: Another spinoza challenge
- From: Dennis \(Icarus\)
- Re: Another spinoza challenge
- References:
- Another spinoza challenge
- From: spinoza1111
- Re: Another spinoza challenge
- From: Richard Heathfield
- Re: Another spinoza challenge
- From: luserXtrog
- Re: Another spinoza challenge
- From: luserXtrog
- Re: Another spinoza challenge
- From: Flash Gordon
- Re: Another spinoza challenge
- From: Dennis \(Icarus\)
- Re: Another spinoza challenge
- From: Flash Gordon
- Re: Another spinoza challenge
- From: Dennis \(Icarus\)
- Re: Another spinoza challenge
- From: Flash Gordon
- Re: Another spinoza challenge
- From: Dennis \(Icarus\)
- Re: Another spinoza challenge
- From: Flash Gordon
- Re: Another spinoza challenge
- From: Dennis \(Icarus\)
- Re: Another spinoza challenge
- From: Flash Gordon
- Re: Another spinoza challenge
- From: Dennis \(Icarus\)
- Another spinoza challenge
- Prev by Date: Re: (u8 a) = (u16) b
- Next by Date: Re: A C showstopper
- Previous by thread: Re: Another spinoza challenge
- Next by thread: Re: Another spinoza challenge
- Index(es):
Relevant Pages
|