aschwarz1...@verizon.net schrieb:
Thanks Kai. I do have what I hope is a more specific subjective reason for
saying that I think the existing diagnostics should be changed. Fundamentally,
what is provided in the messaging is not an indication of what is wrong, but an
indication of what is required to repair the fault. My objections then become:
1: As an old man full of wisdom, most developers can't distinguish a
'primary-expression' from a washing machine. Further, to determine
Well, here I think that such people should perhaps put down the keyboard
and back away from using the compiler slowly. That's about the same as
driving a car without knowing what a stop sign means.
At least if they're unable to infer that a primary expression is a kind
of expression, and there's no expression between [ and ].
what correction might be needed most users would have to research
the C++ standard (or other standardized document supported by the
g++ development community) to find out exactly what constitutes a
'primary-expression'.
Let me put it like this: in this particular case, either it isn't
particularly hard for the progammer to realise that he left out the
index expression he wanted to write, or if that wasn't the mistake it
demonstrates a rather fundamental misunderstanding of the language and
he desperately needs to consult *something* to learn what he's been
missing - no possible compiler message could close this hole in education.
2: It puts an obligation on the g++ development community to ensure
that the messaging is consistent with documentation and that if the
term 'primary-expression' changes then g++ will change the messaging
to conform to the new term.
It's directly from the language standard. If the standard changes
(presumably for more reason than not liking the term), that place in the
compiler needs changing anyway.
And really, I *like* it when the compiler uses terms directly from the
language standard, instead of inventing some other terms. I can search
for those terms in the standard, and most other people talking about the
standard will use the same terms.
3: The cause of the error is more specific than it's solution. The cause
of the fault is the user (in this case me) provided something that
was wrong. It wasn't the lack of a 'primary-expression' but the
existence of the illegal constructs. My conjecture is that if the
message says "you did this wrong" then the user would have an easy
time of finding a fix.
It could well have been a typo for all the compiler knows, where you
inadvertantly left out the index.
I don't argue with the details of my wording. My intent is not to show that I am a better
wordsmith but that the existing diagnostic messages are not specific enough. From Item 1:
above, in order for the average user to fix the error the user must research the terms
used, then compare the syntax given with the actual fault, and then fix the error. If the
message say "this is the fault", the research goes the way of the
woolly-mammoth.
The paradigm is that the message should provide the minimum amount of
information required to identify the syntax/semantics which caused the failure.
And in this case, I believe that the original message does just that,
whereas your proposal doesn't.