comma operator: keep away?
Jim Shankland
jas at ernie.Berkeley.EDU
Wed Apr 19 02:41:38 AEST 1989
In article <628 at gonzo.UUCP> daveb at gonzo.UUCP (Dave Brower) writes:
[A long diatribe against use of the comma operator in all contexts except
macro bodies, and, sometimes, "for" loop initialization and continuation.]
Granted, everyone should write code that is easily understandable by
others. Granted, also, that the way to do that depends on idioms in
common use in a particular language: constructs that are common usage
in, e.g., LISP, may be obscure in C. Granted, finally, that it is quite
possible to write obscure C code by using the comma operator (and in
countless other ways).
I still suggest that a C programmer who understands:
(A) if (x->in_use)
{
x++;
y++;
}
but who is mystified by:
(B) if (x->in_use)
x++, y++;
had best be investigating alternate career paths.
The goal daveb at gonzo is pursuing is an admirable one: how can we get
programmers, especially masses of programmers, to write code that
is correct, understandable, and modifiable by others, in reasonable
time? It is certainly one of the most important questions in
programming, and answers have been slow in coming. I understand
and sympathize with the temptation to tilt at windmills; but it
won't kill the dragons.
The world is full of bad programmers. A magic potion that would turn
them all into good programmers would be a useful thing, indeed.
Brings to mind the (surely apocryphal) story about the ne'er-do-wells
who finagled an NSF grant to research ways to turn cow shit into butter.
Having partied away the entire grant, they applied for supplemental
funds, with the argument: "We've gotten it to spread like butter,
now we need more money to work on the taste."
Exorcising the comma operator from bad code may make it spread better.
The taste, alas, remains unchanged.
Jim Shankland
jas at ernie.berkeley.edu
"Blame it on the lies that killed us, blame it on the truth that ran us down"
More information about the Comp.unix.questions
mailing list