home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / cplus / 13020 < prev    next >
Encoding:
Text File  |  1992-08-29  |  1.5 KB  |  39 lines

  1. Path: sparky!uunet!zephyr.ens.tek.com!uw-beaver!news.u.washington.edu!usenet.coe.montana.edu!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!att!dptg!ulysses!allegra!alice!ark
  2. From: ark@alice.att.com (Andrew Koenig)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: complex classes and temporary destruction.
  5. Message-ID: <23578@alice.att.com>
  6. Date: 28 Aug 92 15:33:09 GMT
  7. References: <MCGRANT.92Aug26232410@rascals.stanford.edu> <23563@alice.att.com> <64821@cup.portal.com>
  8. Reply-To: ark@alice.UUCP ()
  9. Organization: AT&T Bell Laboratories, Murray Hill NJ
  10. Lines: 27
  11.  
  12. In article <64821@cup.portal.com> Aurelius@cup.portal.com (Mark Christian Barnes) writes:
  13.  
  14. >  Have the temporary "inherit" (for lack of a better word) the
  15. > storage class of p. If p is an auto variable then 's+t' should
  16. > be auto too. Destroy p and 's+t' together. If p is static, then
  17. > perhaps have 's+t' be static as well, onc instance of 's+t'
  18. > gets re-used each time the statement is executed.
  19.  
  20. I'm afraid that wouldn't work.  Consider this:
  21.  
  22.     char* I(char* x) { return x; }
  23.  
  24. The function I (for identity) just returns its argument, but to make things
  25. difficult, it is compiled separately.  Now, you would like
  26.  
  27.     char* p = s+t;
  28.  
  29. to cause the temporary for s+t to stick around as long as p does,
  30. but what are you going to do about this?
  31.  
  32.     char* p = I(s+t);
  33.  
  34. There's no way to know what I() does, so what basis do you have for
  35. letting the lifetime of p affect that of s+t?
  36. -- 
  37.                 --Andrew Koenig
  38.                   ark@europa.att.com
  39.