Re: Compiler evaluation of parameters

albaugh@agames.com (Mike Albaugh)
29 May 1999 01:08:50 -0400

          From comp.compilers

Related articles
Compiler evaluation of parameters balasubr@cs.uga.edu (Bala Narasimhan) (1999-05-27)
Re: Compiler evaluation of parameters albaugh@agames.com (1999-05-29)
| List of all articles for this month |

From: albaugh@agames.com (Mike Albaugh)
Newsgroups: comp.compilers
Date: 29 May 1999 01:08:50 -0400
Organization: Atari Games Corporation
References: 99-05-139
Keywords: C, design

Bala Narasimhan (balasubr@cs.uga.edu) wrote:
: I would like to know why some C compilers evaluate and push function
: parameters from right to left will some others do it from left to right?
: Thank you,
: Bala
: [Right to left makes it easier to match up varargs arguments at runtime.
: Left to right is marginally easier to generate code for at compile time.
: It's one of those underwear-like things, you like what you like. -John]


And of course, some compilers for various languages (including
C) evaluate the parameters in arbitrary (sometimes interleaved, as the
comma separating parameters is _not_ a "sequence point") order, and
don't "push" them at all...


One of my "favorite" memories is of attending a talk by a Very
Famous Asic Company on their new procedural design tools (pre-
VHDL/Verilog). As the tool-guru walked through some examples, I could
tell that his tools, based on <language redacted>, depended critically
on the order of evaluation of parameters. One of the <language>
developers was also at the talk, and since I was not familiar with the
language, I asked at the break: "Do you guaranteee the order of
evaluation of parameters?", to which he replied "Of course not. Why?".
I then dragged him over to the tool-smith, and asked that worthy: "Do
you depend on the order of evaluation of parameters?", to which _he_
replied "Of course. Why not?". I left them together, with the
admonition that "You two need to talk" :-)


Mike
| albaugh@agames.com


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.