From: | genew@mail.ocis.net (Gene Wirchenko) |
Newsgroups: | comp.compilers |
Date: | 8 Jun 2003 22:09:20 -0400 |
Organization: | Posted via Supernews, http://www.supernews.com |
References: | 03-05-211 03-06-015 03-06-054 |
Keywords: | design |
Posted-Date: | 08 Jun 2003 22:09:19 EDT |
ericmuttta@email.com (Eric) wrote:
[snip]
>I have often wondered how specifying evaluation order impacts
>implementation. The arguments I have heard for it are:
>
>- it allows consistency between different compilers hence allowing
>code portability between compilers
>
>- it allows one to take advantage of evaluation order in expressions
>
>The second one sounds dubious at first but thinking about it, we
>always rely on our code executing from top to bottom and write the
>code so its dependant on that execution order. So then, is it
>unresonable to specify that evaluation order is left-to-right (or
>vice-versa)? If so, what are the arguments for leaving the order
>undefined? (I have heard something related to efficiency and register
>allocation during procedure invocations, but no explanation was
>given).
Reversing that, you can take advantage of evaluation order. It
might be possible to optimise out constants by reordering evaluation:
#define OFFSET1 5
#define OFFSET2 15
...
... someint + OFFSET1 + OFFSET2 ...
The natural order for most programmers appears to be variable
followed by constant(s).
[snipped previous]
Sincerely,
Gene Wirchenko
Return to the
comp.compilers page.
Search the
comp.compilers archives again.