Liste des Groupes | Revenir à cl c |
On 08/09/2024 09:58, Michael S wrote:On Sun, 8 Sep 2024 05:44:16 +0200
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
On 06.09.2024 13:34, Bart wrote:>>
In more complicated cases in languages, then some asymmetry does
come up. For example, suppose C allowed this (my language allows
the equivalent):
>
(c ? a : b) = x;
In Algol 68 you can write
>
IF c THEN a ELSE b FI := x
>
or, in a shorter form, as
>
( c | a | b ) := x
>
if you prefer.
Are you sure?
It seems to me that you got it backward.
The point here is that you can write such a 2-way select on the LHS
of an assignment. C doesn't allow that unless you wrap it up as a
pointer expression:
*(c ? &a : &b) = x;
In language like C, the LHS of an assignment is one of four
categories:
A = Y; // name
*X = Y; // pointer
X[i] = Y; // index
X.m = Y; // member select
A is a simple variable; X represents a term of any complexity, and Y
is any expression. (In C, the middle two are really the same thing.)
Some languages allow extra things on the LHS, but in C they can be
emulated by transforming the term to a pointer operation. In the same
it can emulate pass-by-reference (which objects which are not arrays!)
Les messages affichés proviennent d'usenet.