Expression sequencing query

Peter S. Shenkin peters at cubsvax.UUCP
Sat Oct 11 04:12:56 AEST 1986

In article <umcp-cs.3769> chris at umcp-cs.UUCP (Chris Torek) writes:
>If you want `a+b' to be done first, then `result + c', use
>	result = a + b;
>	result += c;
>The solution is trivial, and the `problem' is well documented.
>						...I never expect
>parentheses to do more than override default precedence, so it is
>not `totally counter-intuitive' to me.

One of the attractions of C is its elegance and conciseness of expression;
having to declare a variable only for the purpose of defining order of
evaluation, even when the expression is extremely simple, is inelegant and 
inconcise, and the requirement to do so can easily double the size (as measured 
by the number of lines) of source code in numerical work where rounding error
is significant and such order has to be thoroughly thought through.

C wasn't originally designed for such applications, of course, but now that
we're going to be able to do single-precision arithmetic across function
calls there's going to be less and less reason to avoid using C;  unfortunately,
this parentheses thing is going to remain one of them.

I understand the reason for the accepted convention, and I accept that reason,
but even if it's necessary it's a necessary evil;  let's not make a virtue
out of it.  I wish there were some way of forcing order of execution, to 
this extent anyway, within a line.

Peter S. Shenkin	 Columbia Univ. Biology Dept., NY, NY  10027
{philabs,rna}!cubsvax!peters		cubsvax!peters at columbia.ARPA

More information about the Comp.lang.c mailing list