home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12739 < prev    next >
Encoding:
Internet Message Format  |  1992-08-21  |  1.6 KB

  1. Path: sparky!uunet!elroy.jpl.nasa.gov!ames!pacbell.com!tandem!UB.com!igor!thor!rmartin
  2. From: rmartin@thor.Rational.COM (Bob Martin)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: destruction of temporaries
  5. Message-ID: <rmartin.714433518@thor>
  6. Date: 21 Aug 92 21:45:18 GMT
  7. References: <1992Aug17.073500.24115@ericsson.se> <TMB.92Aug20142610@arolla.idiap.ch> <1992Aug20.190313.3407@lucid.com> <2285@devnull.mpd.tandem.com>
  8. Sender: news@Rational.COM
  9. Lines: 31
  10.  
  11. rgp@mpd.tandem.com (Ramon Pantin) writes:
  12.  
  13. >I've got a simple (poor man's?) solution to this problem:
  14.  
  15. >    Let the compiler destroy temporaries as soon as it wishes
  16. >    to do so, with the exception of objects for which a member function
  17. >    that has been declared with a new keyword (say "longlived")
  18. >    _might_ have been executed, in which case the object persist
  19. >    until the end of the function (or some other convenient
  20. >    place for destruction).
  21.  
  22. [...]
  23.  
  24. >What do you think? 
  25.  
  26.  
  27. I don't favor any technique which makes the destruction of temporaries
  28. dependent upon decisions made by the programmer.  The language is
  29. already complex enough without that. 
  30.  
  31. In my opinion, temporaries should be deleted as soon as possible.  The
  32. compiler should issue warnings in any situation where a pointer or
  33. reference to a temporary is stored (and thus may be dangling after the
  34. destruction of the temporary).  I think this is sufficient.  
  35.  
  36.  
  37. --
  38. Robert Martin                        Training courses offered in:
  39. R. C. M. Consulting                       Object Oriented Analysis
  40. 2080 Cranbrook Rd.                        Object Oriented Design
  41. Green Oaks, Il 60048 (708) 918-1004       C++
  42.