Expression sequencing query

Rahul Dhesi 00R0DHESI%bsu.csnet at CSNET-RELAY.ARPA
Thu Oct 16 14:48:58 AEST 1986


Peter S. Shenkin <cubsvax!peters at columbia.ARPA> writes:
<In article <umcp-cs.3769> chris at umcp-cs.UUCP (Chris Torek) writes:
<<	result = a + b;
<<	result += c;
<...
<...I wish there were some way of forcing order of execution, to 
<this extent anyway, within a line.

Try this:
     {int t = a + b; result = t + c;}  /* note:  force evaluation order */

This construct is general and it achieves the purpose.  The extra variable
exists only in the block and doesn't clutter up the rest of the program.  And 
its very presence shouts "Careful!" to next person who modifies the code.  
C doesn't cry wolf.  Other languages do. 


                                Rahul Dhesi <dhesi%bsu at csnet-relay.ARPA>
                                !seismo!csnet-relay.ARPA!bsu!dhesi
                                Yes, I know they go the wrong way.



More information about the Comp.lang.c mailing list