tps@sdchem.UUCP (Tom Stockfisch) (10/22/86)
In article <2809@watmath.UUCP> rbutterworth@watmath.UUCP (Ray Butterworth) writes: >> The ANSI C draft standard provides the unary plus operator for coercing >> evaluation order. Thus >> a = +(b + c) + +(d) ; >> should force the sum of b+c to be calculated and added to d.... > >Does X3J11 (or any other C "standard") say anything about the >order of evaluation of (possibly redundant) cast expressions? > >e.g. ( ((double)(a+b)) + ((double)(c+d)) ) > >where a, b, c, and d may or may not be type (double)? > >It would certainly be prettier than the unary " +" operator, >and certainly more obvious that the programmer really did want >the given grouping. I find the c a s t much harder to read. I much prefer to have all alphanumeric objects in an expression be variables, and all operators to be non-alphanumeric. In addition, for numeric expressions, the fewer the parentheses the better, since they tend to be profuse. I don't understand why you think the intent is clearer with the cast. The sole purpose (I think) of unary plus is to force evaluation order, whereas casts are normally used for type conversion. In your example, if a, b, c, and d were all doubles, I would be very confused about the purpose of c a s t i n g them to double. -- Tom Stockfisch, UCSD Chemistry