home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Answers on a postcard...
- Message-ID: <1992Sep14.172514.9790@taumet.com>
- Organization: TauMetric Corporation
- References: <1992Sep11.174716.3699@taumet.com> <92256.150512KKEYTE@ESOC.BITNET> <1992Sep13.160033.7735@taumet.com> <1992Sep13.204500.16311@tfs.com>
- Date: Mon, 14 Sep 1992 17:25:14 GMT
- Lines: 40
-
- eric@tfs.com (Eric Smith) writes:
-
- >In article <1992Sep13.160033.7735@taumet.com> steve@taumet.com (Steve Clamage) writes:
- >>It would be possible to change the rules so that order of evaluation
- >>was preserved for overloaded versions of operators "&&", "||", and ",".
- >>Any proposal to do so would have to show some good reason why the
-
- >Why not just require all function arguments to always be evaluated left
- >to right? That would simplify the language, shorten its description,
- >make it easier for novices to learn, and would not break any existing
- >bug-free code. I never did understand the value of leaving such
- >questions open, which accomplishes nothing useful and makes bugs
- >behave differently with different compilers.
-
- The current rule (undefined order of evaluation of function arguments)
- is inherited from C (K&R1, p50). C had the rule in order to allow the
- most efficient code generation or compiler operation. Prior to the C
- standard, different compilers accordingly used (and still use)
- different methods for argument evaluation and passing.
-
- To see one difficulty, C compilers typically push arguments onto the
- stack rightmost first. This assures the called routine that the
- first (leftmost) argument is on the top of the stack. If you pass
- arguments on a stack, you have to do this for C, where no prototype
- is needed, or for C and C++ with variable-argument functions. (Of
- course, other argument-passing methods may be used.)
-
- If the arguments must be evaluated left to right, it forces the compiler
- either to keep around arbitrary amounts of argument calculation, or to
- create extra temps. (I knew of one compiler which generated code to
- reverse the arguments on the stack after pushing them, to handle
- inter-langauge calls with different argument orders.)
-
- When we propose adding a language restriction which was not there
- originally, we have to ask what problem does it solve, how severe
- and how common is the problem, and what is the cost of the solution.
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-