Array by value
Martin Minow
minow at decvax.UUCP
Fri Aug 19 08:39:51 AEST 1983
Arnold Robbins suggests adding the ` operator to C to mean
"array by value" as in:
int a[10]; b[10];
...
`a = `b; /* I may have misrembmered the syntax */
There are several problems with this. First, all C expressions
return a value, so I should be able to write statements such
as
if ((`a = `b) != 0)
which is going to cause great pains for compiler writers.
The other problem is that this suggestion rejects one of the
primary C design philosophies -- that of making "easy things
easy and hard things hard". Most compiler writers will
generate something like "`a = `b":
_bcopy(&a[0], &b[0], sizeof a);
A suitably written _bcopy will run at memory speeds for all non-trivial
cases.
I am willing to bet that all the reasonable "array by value"
operations could be implemented just as efficiently by
a macro preprocessor.
I should also note that Andrew's other suggested operator, '$'
is valid in identifiers in Vax-11C, Decus C, and probably
a few other PDP-11 compilers running on Dec machines. ('$' is
necessary to access system-wide variables on Dec operating
systems.)
Martin Minow
decvax!minow
More information about the Comp.lang.c
mailing list