Keith Thompson said:
jameskuyper said:
(e-mail address removed) wrote: [...]
i don't think the operator can return a value.
Operators (or more accurately, expressions that contain an
operator) normally return a value, and assignment expressions are
no exception to that rule. Changing the value of 'x' is described
by the C standard as a side-effect - of course, that side-effect
is usually the entire reason for using an assignment expression,
but it's still "just" a side-effect as far as the standard is
concerned.
A quibble about terminology:
Functions *return* values. Expressions *yield* values.
In (at least) one place C89 uses the word 'return' to describe the
value yielded by any of several operators, and in another it uses
the word 'return' in connection with the assert macro. C99 also
uses the word in these ways.
It's nearly the same thing, and it wouldn't be a tragedy if we
used the same word for both, but I find it helpful to keep the two
concepts distinct.
I can understand that, although personally I use the word 'return'
freely with regard to operators, perhaps because I think of them,
in essence, as disguised functions.
Note that the editor of n1256.pdf (C99 with the three
Technical Corrigenda merged in) went through and changed the
wording to use "yield" consistently for the results of
expressions.
Ah, you see? You already knew!