YAAO (yet another assignment operator)
Lars Pensj|
lars at myab.UUCP
Thu Dec 27 06:39:53 AEST 1984
x
I like the idea of a assignment operator in the form
X <binop>= Y;
(but I am not sure i want it implemented in the language C).
Some operators will be redundant, like ',='. I also question
the usefulness of '.='.
I can see two purposes of this <binop>= operator:
1. More dense, compact or readable programs.
2. Make more efficient programs when the compiler isn't smart enough
to see this himself.
Point 1 can be somewhat satisfied using the preprocessor.
In this case, I am more interested in point 2. Why not expand this
to the more general case where
X = ... X ...;
can be rewritten to an expression where the address of X only needs to
be calculated once. The syntax for this could be
let X = expr in ... X ...;
for example
let x = a[j*10+i] in x = func(x);
This example shows a case where the compiler could not do this optimization
if 'j' or 'i' was global variables. Another syntactic form could be
X = expr @ ... X ...;
This construction already exists in some languages.
More information about the Comp.lang.c
mailing list