Re: Another spinoza challenge



Dennis (Icarus) wrote:
"Flash Gordon" <smap@xxxxxxxxxxxxxxxxx> wrote in message news:umsdm6xp9a.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxx
Dennis (Icarus) wrote:
"Flash Gordon" <smap@xxxxxxxxxxxxxxxxx> wrote in message news:6b0bm6xh9s.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxx
Dennis (Icarus) wrote:
"Flash Gordon" <smap@xxxxxxxxxxxxxxxxx> wrote in message news:91s9m6x8mq.ln2@xxxxxxxxxxxxxxxxxxxxxxxxxx
<snip>

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

Sure.

How can something that causes compilation compilation to abort be considered valid on that 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).

Didn't say it was a #define.

No, but *I* said it was on a specific implementation, and one provided by the implementation for its own use.

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).

Only if there is a conflict. That could hapen if the symbol is defined twice or in conflicting ways, which is true of...well..any identifier. Whether beginning with an underscore or not.

You raised this before, and as I tried to point out that is not a reasonable objection.

I'm talking about the IMPLEMENTATION making the code invalid, not some other error on the code. I'm talking about the IMPLEMENTATION making the following translation unit invalid
int _MAX_POWER;

I think it perfectly reasonable to tell a beginner (and have the answer to a beginner test) that it they are not allowed to use names which cannot on all implementations be used in a one line C file containing the single definition
int nameinquestion;

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!

By failing "yes", you're saying no one can use it for defnition/declaration, lhs, rhs- that there is no validity for such an identifier AT ALL.

No, by failing it I'm saying that the person being tested thinks they are free to use the identifier which is WRONG.

And that is wrong. If you want to restrict validity to be what should be defined by an application (keying off the identifies beginning with _ belonging to implementation or all caps typically referring to macros) then that should be part of the question. Otherwise, you're just asking what's a valid identifer - regardless of context.

Ah, but in SOME contexts it is NOT a valid identifier (i.e. where an implementation has done something making it invalid as an identifier), so if you ignore context the only safe assumption is that it is NOT valid.

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.

Never said it wasn't.

If you don't think it is reasonable, why argue against it without at least acknowledging that it is reasonable?

But it does read more into the question that what was asked.

I disagree, and I've explained why in the context of the question it is a reasonable interpretation. I've also explained why a beginner should start off by being told they should not use any identifier starting with an underscore (which would lead the student to give the answer that it is invalid).
--
Flash Gordon
.



Relevant Pages

  • Re: Another spinoza challenge
    ... How can something that causes compilation compilation to abort be considered valid on that implementation? ... It should be pretty clear that it is, reserved for the implementation because of the leading _, but it is a valid identifier. ... I think it perfectly reasonable to tell a beginner that it they are not allowed to use names which cannot on all implementations be used in a one line C file containing the single definition ... The second paragraph is reasonable context for the question. ...
    (comp.lang.c)
  • Re: Another spinoza challenge
    ... How can something that causes compilation compilation to abort be considered valid on that implementation? ... It should be pretty clear that it is, reserved for the implementation because of the leading _, but it is a valid identifier. ... Said nothing about context, ... I think it perfectly reasonable to tell a beginner that it they are not allowed to use names which cannot on all implementations be used in a one line C file containing the single definition ...
    (comp.lang.c)
  • Re: Does this program have undefined behavior?
    ... An identifier list declares only the identifiers of the parameters of ... int main{ ... int bar() { ...
    (comp.lang.c)
  • Error in Building the Passthrough NDIS IM Driver from DDK
    ... 'NdisIMGetDeviceContext' undefined; assuming extern returning int ... 'NDIS_MINIPORT_CHARACTERISTICS': undeclared identifier ... '.MajorNdisVersion' must have struct/union type ...
    (microsoft.public.development.device.drivers)
  • Re: "Referenced type "
    ... object and an int value, especially in languages having proper constants. ... Both x and y are of type int, yet &x is allowed but not &y. ... `x' is an identifier, ...
    (comp.lang.c)