Liste des Groupes | Revenir à cl c |
Bart <bc@freeuk.com> writes:If you go back far enough, someone was questioning the use of a 2-way selection (what in C would be expressed using ?:) on the left of an assignment, in an example from another language.
[...]It's not that complicated, not with C anyway.I agree, there's only one thing to consider. The LHS of an
>
Because in C, if you take the 3-4 categories of LHS in assignments
(ignore the esoteric ones, and [] and . are really the same), there is
only one top-level lvalue node to consider.
assignment is a modifiable lvalue.
We've spent a lot of time arguing about how any "categories" there
are for the LHS of an assignment. If I recall correctly, the whole
thing started when you stated that "the LHS of an assignment is
one of four categories", leading to a debate about whether four
is the correct number.
Enumerating the kinds of expressions that can be modifiable
lvalues is interesting, I suppose, but are A and (A) in different
"categories"? Is it important to count generic selections and
compound literals?
Who cares, and why?
And my comments were in reply to this from WH:And yet, I was doing that in the 1980s on my toy compilers. So that'sOk, it's not that hard to implement things that are not valid C.
not that hard either.
Well quite. WH was trying to make it out it's a big deal, but it's usually a no-op (ie. nothing needs to be done in an actual compiler).What exactly /is/ lvalue conversion? What is converted to what?This is specified in the C standard (6.3.2.1p2 in C11, 6.3.3.1p2
in C23 drafts). I suggest you read it.
An lvalue (an expression that designates an object) is converted
to the value stored in the designated object. This conversion
(adjustment) does not occur on the LHS of an assignment or in
several other contexts.
It might have been clearer to say that the expression is adjusted
from an expression that designates an object (an lvalue) to an
expression that yields the value of that object (not an lvalue)
Note that this is not a run-time conversion,
like a conversion of anNo, there an actual conversion is needed, usually. (Maybe the implementation language only stores numeric constants as floats, so only the type tag changes.)
integer value to a floating-point value.
Les messages affichés proviennent d'usenet.