Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!rutgers!seismo!gatech!cuae2!ltuxa!ttrdc!levy From: levy@ttrdc.UUCP (Daniel R. Levy) Newsgroups: net.lang.c Subject: Re: Expression sequencing query Message-ID: <1243@ttrdc.UUCP> Date: Tue, 14-Oct-86 23:12:30 EDT Article-I.D.: ttrdc.1243 Posted: Tue Oct 14 23:12:30 1986 Date-Received: Mon, 20-Oct-86 23:29:14 EDT References: <760@oakhill.UUCP> <111@titan.UUCP> <468@jc3b21.UUCP> <160@geac.UUCP> <559@cubsvax.UUCP> Distribution: net Organization: AT&T, Computer Systems Division, Skokie, IL Lines: 52 In article <559@cubsvax.UUCP>, peters@cubsvax.UUCP (Peter S. Shenkin) 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 In C, you can put more than one statement on a line! So it would be feasible, if awkward, to do something like float a,b,c,d,e,t; t=a+b;t+=c;d*=t;d/=e; for the FORTRAN D=(D*((A+B)+C))/E Obviously it's possible but unnecessary to use four different lines: t=a+b; t+=c; d*=t; d/=e; -- ------------------------------- Disclaimer: The views contained herein are | dan levy | yvel nad | my own and are not at all those of my em- | an engihacker @ | ployer or the administrator of any computer | at&t computer systems division | upon which I may hack. | skokie, illinois | -------------------------------- Path: ..!{akgua,homxb,ihnp4,ltuxa,mvuxa, go for it! allegra,ulysses,vax135}!ttrdc!levy