home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12345 < prev    next >
Encoding:
Text File  |  1992-08-14  |  1.4 KB  |  35 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!destroyer!sol.ctr.columbia.edu!eff!world!pkturner
  3. From: pkturner@world.std.com (Prescott K Turner)
  4. Subject: Re: destruction of temporaries
  5. Message-ID: <BszApE.49v@world.std.com>
  6. Organization: The World Public Access UNIX, Brookline, MA
  7. References: <46140@sunquest.UUCP>
  8. Date: Fri, 14 Aug 1992 14:53:38 GMT
  9. Lines: 24
  10.  
  11.  
  12. Bill Raves writes:
  13. > For example, Jim Adcock has suggested
  14. > (<70784@microsoft.UUCP>) "NEVER rely on unnamed temporaries to do
  15. > anything...", but this would seem to erode the expressiveness of the
  16. > language: constructs like "foo(x + y)" and "foo()[i]" would no longer
  17. > be permissible. 
  18.  
  19. I second Adcock's advice.  Actually, those constructs can be made to
  20. work at the expense of some extra implementation effort, and some
  21. execution cost.  But the cost is not an impediment if it's being compared
  22. to code which is not portable to the platforms one needs.
  23.  
  24. What the programmer must beware (in the absence of garbage 
  25. collection) is pointers and references that refer to unnamed objects.
  26. The standards committee may eventually mandate that these objects 
  27. hang around somewhat longer, but not indefinitely.
  28. Classes which rely on such pointers entail pitfalls.  Late destruction
  29. of temporaries (as in cfront) reduces but does not eliminate
  30. the problem.
  31. --
  32. Prescott K. Turner, Jr.
  33. 13 Burning Tree Rd., Natick, Massachusetts USA
  34. Internet: pkturner@world.std.com
  35.