Kaz said:
Interesting, I tried to use the `cast' operator.
previous = (void) 0;
An operator is not as something that yields a value.
If you don't like ``while'' being called ``operator'', do you have an
alternative?
It is a keyword. But ``char'' is a also a keyword; this is a lexical category,
not a semantic category. We have another name for ``char'' when it is
engaged in its semantic role, like ``type specifier''. We don't only
call it a keyword.
So, semantically, what is ``while''? It is not a statement, because a while
statement is the whole syntactic unit ``while ( expr ) statement ''.
We have terminology for other parts of the while statement: the expr is
a ``controlling expression'' and the statement is referred to as ``loop body''
defined in 6.8.5 in italics.
So that leaves ``while''. What is that?
`while' is part of the syntax of two statement forms, referred
to informally as "the while statement" and "the do-while statement"
and described more rigorously by the grammar productions in 6.8.5.
Why should it need any further name than "part of the syntax?"
We know of "the ternary operator," but do we have separate terms
for the '?' and ':' tokens contribute to it? No, they're just part
of the syntax. We know how to put a label on a statement, but do we
have a special name for the ':' that goes after the label identifier?
No, it's just part of the syntax. We know that we must parenthesize
the controlling expression that follows `while' or `if' or `switch',
but do we have a special name for those parentheses? No, they're
just part of the syntax. What more is needed?
If you have no name for the role that the keyword ``while'' plays in the while
statement, you have no basis for objecting to my calling it an operator.
Throughout 6.5 and 6.10, the Standard lists various things and
calls them "operators." It does not apply the term to anything
else, so I believe the list should be regarded as comprehensive,
taken as complete.
In particular, the word "operator" appears nowhere in 6.8, not
even in the non-normative bits.
Propose your alterative instead, and argue why it is better than extending
the term ``operator''.
"Must every little keyword have a jargon all its own?" (With
apologies to Jerome Frank).
The `while' keyword -- and `for' and `if' and `return' and
others not mentioned -- are a part of the required syntax of the
statements in which they appear, that's all. We don't need a
special name for the white space that separates `int' from `main';
why should we need a special name for `while'?
The term already seems to do that, or is on practically on the verge.
It appears in italics in 6.4.6 Punctuators, where it is given a meaning
that appears not to exclude symbols like ``for'' and ``while''.
A punctuator is a symbol that has independent syntactic and semantic
significance. Depending on context, it may specify an operation to be
performed (which in turn may yield a value or a function designator,
produce a side effect, or some combination thereof) in which case it is
known as an <italics>operator</italics> (other forms of operator also exist
in some contexts). An operand is an entity on which an operator acts.
See, punctuators can be operators, but the set of operators is broader. We are
not given any specific closed list of symbols such that those are called
operators, and no others. Simply, an unspecified set of other forms may be
operators. Operators need not even be symbols. For instance cast operators are
combinations of symbols. Operators need not produce a value, and are
context-dependent.
Okay; the list of punctuators mentions that some of them are
operators, and mentions that some things not listed (non-punctuators)
are also operators. But it does not follow that everything not
listed is an operator! Would you describe the decimal constant 42
as an "operator," simply because it's not listed as a punctuator?
Or how about the aforementioned white-space "operator?"
(For an amusing sidelight, look up the Whitespace programming
language.)
Can someone make a convincing argument that while and return must
not be called operators?
My argument boils down to this: The Standard does not use the
term "operator" to refer to `while', so we shouldn't use it that
way either.