Sujet : Re: Top 10 most common hard skills listed on resumes...
De : Keith.S.Thompson+u (at) *nospam* gmail.com (Keith Thompson)
Groupes : comp.lang.cDate : 08. Sep 2024, 20:19:18
Autres entêtes
Organisation : None to speak of
Message-ID : <87v7z62bt5.fsf@nosuchdomain.example.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
User-Agent : Gnus/5.13 (Gnus v5.13)
Waldek Hebisch <
antispam@fricas.org> writes:
Bart <bc@freeuk.com> wrote:
But the feature (using them in lvalue contexts) was rarely used.
(** This is:
(a, b, c) = 0;
in C, which is illegal. But put in explicit pointers, and it's suddenly
fine:
*(a, b, &c) = 0;
So why can't the compiler do that?)
A C compiler doesn't do that because the language doesn't allow it.
An expression whose top-level operator is a comma operator is not
an lvalue in C, even if the operands are lvalues. It could have been,
but it isn't.
The second really is
>
(a, b, c = 0);
>
I do not know what you expect writing '(a, b, c) = 0', but the above
C meaning probably is not what you want.
I think Bart was talking about a hypothetical feature that allows comma
expressions to be lvalues. The comma operator evaluates both its
operands and yields the value of the right operand. So for example:
(a, b) = 0;
which is a constraint violation in current C, the LHS (a, b) would be
treated as an lvalue that discards a and designates b, which then
becomes the target of the assignment.
It's not an insane idea, and it wouldn't be difficult to specify its
semantics consistently. In fact C++ supports conditional and comma
expressions as lvalues; `(a, b) = 0;` is a constraint violation in C,
but valid in C++. I'm not sure how useful it is.
I use language that allows:
>
(a, b, c) := (b, c, a);
>
that is if there are 3 things on left hand side, then there must
be 3 things on the right hand side.
That's not a comma operator, and I don't think it's relevant to what
Bart is talking about. The comma symbol is used in a lot of different
contexts.
Bart, please jump in if I've misunderstood what you meant.
[...]
-- Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.comvoid Void(void) { Void(); } /* The recursive call of the void */