Unary plus ( + )

Walter Bright bright at dataio.UUCP
Mon Aug 12 19:47:24 AEST 1985


In article <610 at cyb-eng.UUCP> bc at cyb-eng.UUCP (Bill Crews) writes:
>OK, I understand that order of evaluation is not guaranteed.  I assume that
>was done to make compilers easier to write.  Is there any other reason?  Does
>it really make compilers easier to write?

Yes, it really does. The reason is because C provides a very large number
of operators, and therefore an enormous number of combinations of them.
Code generators must be able to handle all this, and so to reduce the
complexity of the task, expressions are usually reorganized and manipulated
until they fit into a relatively small number of forms.

Also, allowing the compiler to reorder the expression within certain
limits allows it to do some optimizations. Most code is not affected by
order of evaluation, and C does allow an order to be forced (by assigning
an explicit temporary), so I think this is very reasonable.



More information about the Comp.lang.c mailing list