Liste des Groupes | Revenir à cl c |
On 12/09/2024 00:47, Ben Bacarisse wrote:Bart <bc@freeuk.com> writes:>
On 11/09/2024 01:02, Ben Bacarisse wrote:Yes, that incorrect explanation.Bart <bc@freeuk.com> writes:>>Sorry, did your remark above suggest I don't know what an lvalue is?That seemed like the obvious explanation for the incorrect information
you gave. Did you post it /knowing/ what other kinds of things are
lvalues in C just to confuse people?
Which incorrect explanation was that?
>
I merely said that LHSs of assigments fall into these categories:
>
A = Y; // name
*X = Y; // pointer
X[i] = Y; // index
X.m = Y; // member select
I dispute that. What I said is very broadly correct. But in this newgroup
you do like to nitpick.
So to you, it is of the greatest importance that somebody doesn't just know
about those four categories that they will be reading and writing all the
time in C code, but also know about:
>
(int){A} = Y;
which they will encounter approximatey never. And it is also vital they
they consider:
>
(A) = (Y);
>
a distinct category.
There might be a case for this for '(Z, A) = Y;' but
that isn't allowed anyway. So it only applies to superfluous
parentheses.
>Clearly I mean VALID LHSs, otherwise they wouldn't be LHSs of assignments!Along with (a) _Generic expressions (where the selected arm is an
>
I've since learnt about a couple of other possible categories; one is with
compound literals like '(int){42} = 0'.
lvalue)
>
The _Generic forms reduce down one of those four.
It is more like a macro,
and if you're going to start with macros, there are unlimited categories
that can be created. If this is merely about syntax, then why not?
>
(I'd also like to see an actual usecase for _Generic on the LHS of an
assignment. Perhaps one where there is a matching (symmetric?) _Generic on
the RHS?)
>and (b) expressions of the form X->m.>
Are there any circumstances where X->m does something different from
(*X).m?
>(I don't count (A), ((A)) etc as aDon't give me "come on!". I was counting forms in the same way that you
separate category; come on!)
were when I said I could think of three more. I was not counting
parentheses.
Keith mentioned this form.
>The other is 'X.m' but when .m is a bitfield;What makes X.m = Y, where m is a bitfield, an extra category? It fits
the X.m = Y pattern perfectly well.
although this has the sameYour categories were syntactic. You were describing forms.
same syntax as above, internally it's somewhat different.
Not entirely. There is behaviour associated with them.
>
Most LHS terms can have & applied in an rvalue context for example;
bitfield accesses can't. So it's something a user of the language needs to
know about.
And internally, my ASTs (where bitfields are supported) use a different
node type when X.m is a bitfield rather than a regular access.
Les messages affichés proviennent d'usenet.