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

  1. Path: sparky!uunet!crdgw1!uakari.primate.wisc.edu!aplcen.apl.jhu.edu!darwin.sura.net!wupost!gumby!yale!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: destruction of temporaries
  5. Message-ID: <TMB.92Aug19113657@arolla.idiap.ch>
  6. Date: 19 Aug 92 15:36:57 GMT
  7. References: <1992Aug17.073500.24115@ericsson.se> <23466@alice.att.com>
  8.     <1992Aug17.211508.6634@lucid.com>
  9.     <1992Aug18.205211.16789@Warren.MENTORG.COM>
  10. Sender: news@ai.mit.edu
  11. Reply-To: tmb@idiap.ch
  12. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  13.     Perceptive)
  14. Lines: 28
  15. In-reply-to: adk@Warren.MENTORG.COM's message of 18 Aug 92 20:52:11 GMT
  16.  
  17. In article <1992Aug18.205211.16789@Warren.MENTORG.COM> adk@Warren.MENTORG.COM (Ajay Kamdar) writes:
  18.  
  19.    So why would the ARM consider the example with a temporary sufficient
  20.    reason to reject the "end of function" approach? To me it appears that
  21.    the "end of function" approach for temporaries would not cause any more
  22.    difficulties or program bugs than those that can already occur even without
  23.    temporaries. So why not reconsider that approach?
  24.  
  25. I don't want my temporaries to hang around until the end of the
  26. function. I often use large temporaries (megabytes), and I see no
  27. reason why they should stick around any longer than I need them.
  28.  
  29. Temporaries should get destroyed as soon as their value has been used.
  30. To make call-by-reference a little more convenient, there is a special
  31. rule for binding references to temporaries, and I guess that's OK.
  32.  
  33. The properties of temporaries are no different (and no worse) than the
  34. properties of automatic variables: pointers to them become invalid
  35. when the object disappears.
  36.  
  37. If you want to be able to implement anything more powerful, you need
  38. (surprise!) garbage collection (as stated in the ARM, p. 268). In the
  39. presence of GC, you would then actually have a choice of destroying
  40. the temporary yourself (the current situation, safe if no pointers to
  41. it have been handed out), or of not destroying it at the end of the
  42. expression and letting the GC take care of it.
  43.  
  44.                     Thomas.
  45.