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

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!sdd.hp.com!mips!carbon!news.cs.indiana.edu!syscon!gator!fang!att!allegra!alice!ark
  2. From: ark@alice.att.com (Andrew Koenig)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Proposal: auto T&
  5. Message-ID: <23508@alice.att.com>
  6. Date: 21 Aug 92 02:07:14 GMT
  7. Article-I.D.: alice.23508
  8. References: <1992Aug19.234913.622@tfs.com> <1992Aug20.171342.3589@sunb10.cs.uiuc.edu> <9223406.29682@mulga.cs.mu.OZ.AU> <1992Aug20.213417.5690@sunb10.cs.uiuc.edu>
  9. Reply-To: ark@alice.UUCP ()
  10. Organization: AT&T Bell Laboratories, Murray Hill NJ
  11. Lines: 30
  12.  
  13. In article <1992Aug20.213417.5690@sunb10.cs.uiuc.edu> pjl@sparc10.cs.uiuc.edu (Paul Lucas) writes:
  14.  
  15. > >>    a = stringfunction( b ) + stringfunction( c );
  16.  
  17. > >What do you mean by "it's not reentrant"? Why not?
  18.  
  19. > *****>    Because the "slot" allocated in the caller would first receive
  20. >     the temporary generated by "stringfunction( b )" then it would
  21. >     be clobbered by "stringfunction( c )" and clobbered yet again by
  22. >     the temporary generated by operator+, assuming it also used this
  23. >     proposed technique.
  24.  
  25. Hardly likely.  The compiler had better allocate different memory locations
  26. for stringfunction(b) and stringfunction(c) regardless of parallelism,
  27. because otherwise how is it going to have them both around to hand
  28. to operator+?
  29.  
  30. >     The problem with that is, what does the compiler do if a
  31. >     function returning an auto& calls itself?
  32.  
  33. No problem: each function allocates memory for the values returned
  34. by the functions it calls directly.  That set is always known at
  35. compile time.
  36.  
  37. Of course, that's no different from what happens now with functions
  38. that return ordinary objects when compiled with a compiler with just
  39. a tiny bit of optimization.
  40. -- 
  41.                 --Andrew Koenig
  42.                   ark@europa.att.com
  43.