Expression sequencing query

Henry Spencer henry at utzoo.UUCP
Sat Oct 11 04:31:34 AEST 1986


> For numerical calculations it would be very nice to be able
> to specify order.  Breaking up the expression into individual ones is  n o t
> a viable option...  I think the best solution would be a unary operator
> with syntax like 'return', so that the compiler would have to respect
> parentheses for order of evaluation of the following statement...
> 	
> 	respect	<expr> ;

X3J11 has not done quite this, but they have provided a way to specify a
"fence" within an expression.  The unary plus operator, originally provided
for relatively minor reasons of consistency, also does this job.  To force
the parenthesized addition in "(a+b)+c" to be done first, write "+(a+b)+c".
(Unary operators have higher priority than binary, so "+(a+b)" is an operand
of the last "+".)  The official definition of the effect is something like
"inhibits regrouping of subexpressions within its operand with subexpressions
outside it".  I can't say that I am in love with the syntax, but the facility
is there.
-- 
				Henry Spencer @ U of Toronto Zoology
				{allegra,ihnp4,decvax,pyramid}!utzoo!henry



More information about the Comp.lang.c mailing list