home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / std / cplus / 2116 < prev    next >
Encoding:
Text File  |  1993-01-25  |  2.1 KB  |  48 lines

  1. Newsgroups: comp.std.c++
  2. Path: sparky!uunet!titan!lpi!pkt
  3. From: pkt@lpi.liant.com (Scott Turner)
  4. Subject: Re: Question about temporaries
  5. Message-ID: <1993Jan25.163150.24449@lpi.liant.com>
  6. Sender: pkt@lpi (Scott Turner)
  7. Organization: Liant Software Corporation
  8. References:  <C1DtoB.FJ3@fiu.edu>
  9. Date: Mon, 25 Jan 1993 16:31:50 GMT
  10. Lines: 36
  11.  
  12. In article <C1DtoB.FJ3@fiu.edu>, feathers@serss0 (Michael Feathers) writes:
  13. > Has the ANSI committee done any more work of the lifetime of temporaries?
  14. > I'm very curious about this aspect of the emerging standard.
  15.  
  16. At the Boston meeting last November, some straw votes were taken to get
  17. the sense of the committee of the whole.  IMO there was a clear leader
  18. among the possibilities which seemed viable at the time.  Unfortunately
  19. no prize was awarded. :-)  38 voted that the following was acceptable,
  20. and none voted that it was unacceptable.
  21.  
  22.      Temporaries are normally destroyed at the end of the statement
  23.      in which they are created.  The exception is that temporaries
  24.      created within a branch of a conditional (?:) operator are destroyed
  25.      when that branch is completed (and analogously for && and ||).
  26.  
  27. I would say that the committee was ready to compromise and decide on this
  28. except for one thing.  Nearly all of the discussion has assumed that we
  29. know what is a "temporary".  When asked directly regarding the formal
  30. argument x in the function
  31.      class C { ...  C (const C&);  ... };
  32.      void f(class C x) {   ... use x ...   }
  33. most people would say x is _not_ a temporary.  On the other hand, a very
  34. popular implementation of C++ gives x the same extended lifetime as a
  35. temporary.  Also, more than one example presented in favor of long-lived 
  36. temporaries has actually needed long-lived formal arguments!  If I recall
  37. correctly, an example was
  38.      String x, y;
  39.      char *z;
  40.      extern char *f(String);
  41.      z = f(x+y);
  42. --
  43. Prescott K. Turner, Jr.
  44. Liant Software Corp. (developers of LPI languages)
  45. 959 Concord St., Framingham, MA 01701 USA    (508) 872-8700
  46. UUCP: uunet!lpi!pkt                          Internet: pkt@lpi.liant.com
  47.