home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / misc / 2767 < prev    next >
Encoding:
Text File  |  1992-08-22  |  2.1 KB  |  62 lines

  1. Newsgroups: comp.lang.misc
  2. Path: sparky!uunet!usc!sdd.hp.com!mips!mips!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!fjh
  3. From: fjh@munta.cs.mu.OZ.AU (Fergus James HENDERSON)
  4. Subject: Re: Small Language Wanted
  5. Message-ID: <9223618.1639@mulga.cs.mu.OZ.AU>
  6. Sender: news@cs.mu.OZ.AU
  7. Organization: Computer Science, University of Melbourne, Australia
  8. References: <BtCFs9.4ox@usenet.ucs.indiana.edu> <173lvpINNiov@network.ucsd.edu>
  9. Date: Sun, 23 Aug 1992 08:41:17 GMT
  10. Lines: 50
  11.  
  12. mbk@lyapunov.ucsd.edu (Matt Kennel) writes:
  13.  
  14. >mdchaney@fractal.ucs.indiana.edu (M Darrin Chaney) writes:
  15. >: Not to fan a flame war, but indeed C++ is _excellent_ for working with
  16. >: complex numbers, etc.  And, nobody will accuse you of using an outdated
  17. >: language.
  18. >
  19. >C++:  complex A, B, C;
  20. >
  21. >C = A + B
  22. >
  23. >{ get A and B, call "+" operator.  Create new temporary structure for
  24. >  result by calling complex constructor.  Run "+" operator. 
  25. >  call overloaded "=" operator.  Copy into C. Delete temporary.}
  26.  
  27. The calls to operator "+" and operator "=" will be inlined.
  28. Smart compilers (including Cfront) will optimize the temporary away.
  29. The resulting object code is exactly the same as would result from
  30. equivalent Fortran.
  31.  
  32. >And can C++ optimize
  33. >
  34. >for (i=1; i<1000; i++) {
  35. >    <junk not altering A and B>
  36. >    C = A + B
  37. >    <more junk not altering A and B>
  38. >    func(C)
  39. >}
  40. >
  41. >by taking out C=A+B as a loop invariant?
  42.  
  43. Yes.
  44.  
  45. >How can it if the "+" and "=" operators could conceivably do *ANYTHING*
  46. >which might possibly alter something else somewhere else.
  47.  
  48. These operators are declared as inline functions, so the
  49. compiler can see exactly what they do and can thus make the
  50. appropriate optimizations.
  51.  
  52. -- 
  53. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  54. This .signature virus is a self-referential statement that is true - but 
  55. you will only be able to consistently believe it if you copy it to your own
  56. .signature file!
  57. -- 
  58. Fergus Henderson             fjh@munta.cs.mu.OZ.AU      
  59. This .signature virus is a self-referential statement that is true - but 
  60. you will only be able to consistently believe it if you copy it to your own
  61. .signature file!
  62.