home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #20 / NN_1992_20.iso / spool / comp / lang / cplus / 13624 < prev    next >
Encoding:
Text File  |  1992-09-14  |  2.4 KB  |  51 lines

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