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

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!uunet.ca!frumious!pat
  3. From: pat@frumious.uucp (Patrick Smith)
  4. Subject: Re: Proposal: auto T&
  5. Message-ID: <1992Aug20.024059.734@frumious.uucp>
  6. Date: Thu, 20 Aug 1992 02:40:59 GMT
  7. Reply-To: uunet.ca!frumious!pat
  8. References: <1992Aug19.234913.622@tfs.com>
  9. Organization: None
  10. Lines: 30
  11.  
  12. eric@tfs.com (Eric Smith) writes:
  13. |auto String& stringfunction(const String& input)
  14. |{
  15. |   // Calculate/create a new temporary or named automatic String
  16. |   // and return a reference to it.
  17. |}
  18. |
  19. |The "auto" in the function return value type tells the compiler to allocate
  20. |the space for that automatic in the stack frame of the caller, instead of
  21. |the stack frame of the called function.
  22.  
  23. How is this different from
  24.  
  25.    String stringfunction(const String& input) { /*...*/ }
  26.  
  27. in the current language?  Here I would (naively?) expect the calling
  28. function to pass the address of a space where the called function
  29. should construct the result, and that that space will probably be
  30. in the stack frame of the caller (certainly not in the stack frame
  31. of the called function, since it must live past the moment when the
  32. called function returns).
  33.  
  34. I also don't see how this would make it any easier for the compiler
  35. to decide when to destroy the object created by the called function
  36. (if that object is a temporary).
  37.  
  38. -- 
  39. Patrick Smith
  40. uunet.ca!frumious!pat
  41. pat%frumious.uucp@uunet.ca
  42.