home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14537 < prev    next >
Encoding:
Text File  |  1992-08-26  |  2.7 KB  |  73 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!mcsun!Germany.EU.net!ira.uka.de!chx400!bernina!bernina!neeri
  3. From: neeri@iis.ethz.ch (Matthias Neeracher)
  4. Subject: Re: incrementation differences/THINK C 4.0 vs. 5.0
  5. In-Reply-To: mxmora@unix.SRI.COM's message of 25 Aug 92 16:26:29 GMT
  6. Message-ID: <NEERI.92Aug26155235@iis.ethz.ch>
  7. Sender: news@bernina.ethz.ch (USENET News System)
  8. Organization: Integrated Systems Laboratory, ETH, Zurich
  9. References: <1992Aug24.223423.24473@kronos.arc.nasa.gov>
  10.     <1992Aug24.232700.7896@Csli.Stanford.EDU> <BtIJq6.3yw@taligent.com>
  11.     <38119@unix.SRI.COM>
  12. Date: Wed, 26 Aug 1992 14:52:35 GMT
  13. Lines: 58
  14.  
  15. In article <38119@unix.SRI.COM> mxmora@unix.SRI.COM (Matt Mora) writes:
  16. >In article <BtIJq6.3yw@taligent.com> keith@taligent.com (Keith Rollin) writes:
  17. >>
  18. >>I don't think that's a valid assumption. Although it might be disconcerting, I
  19. >>don't think there's anything preventing a compiler from evaluating your sample
  20. >>line one way during one compile, and the very same compiler evaluating it a
  21. >>different way during a subsequent compile. ANSI spec section 3.3.16 says "The
  22. >>order of evaluation of the operands is unspecified."
  23. >
  24. >Don't you just love C! All the cool things that you can do are the very
  25. >same things you have to worry about. Pretty soon you'll be writing code like
  26. >this just to be safe. i = i + 1;  :-)
  27.  
  28. No. ++i is perfectly specified.
  29.  
  30. >Why can't there be a smart compiler?
  31.  
  32. A smart compiler works best if it has some degree of freedom, and that's
  33. exactly why order of evaluation is unspecified.
  34.  
  35. >When a compiler doesn't know the best way to go why doesn't it just ask?
  36.  
  37. Because I don't want to come back from a coffee break and have the compiler
  38. wait for an answer.
  39.  
  40. >"not sure how you want the order of evaluation of this line:"
  41. >     lab[i] = temp[i++];  //****THIS IS THE PROBLEM
  42.  
  43. Personally, I'd prefer a B&D approach:
  44.  
  45. "Order of evaluation undefined; I'll pick a different order next time".
  46.  
  47. >Also why can't the compiler say this when a ";" is missing.
  48. >
  49. >Missing an ";" at the end of this line. Should I add one?"
  50.  
  51. Most compilers in fact do something almost like this: They proceed with
  52. parsing as if there had been an ";". You have to be aware, however, that error
  53. recovery is a particularly nasty problem for C parsers (too little redundancy
  54. in the grammar, I suspect).
  55.  
  56. >"Add one and Continue" or "Cancel"
  57. >
  58. >instead of
  59. >
  60. >"Missing a ";" at the end of statement."
  61. >
  62. >and stop compiling. 
  63.  
  64. MPW C continues compiling instead of displaying pretty animal pictures.
  65.  
  66. Matthias
  67.  
  68. -----
  69. Matthias Neeracher                                      neeri@iis.ethz.ch
  70.    "You think people really worship the devil?"
  71.    "Sure. It's the perfect religion--you fuck up, you go to heaven"
  72.                                      -- Andrew Vachss, _Sacrifice_
  73.