home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!uunet.ca!frumious!pat
- From: pat@frumious.uucp (Patrick Smith)
- Subject: Re: Proposal: auto T&
- Message-ID: <1992Aug20.024059.734@frumious.uucp>
- Date: Thu, 20 Aug 1992 02:40:59 GMT
- Reply-To: uunet.ca!frumious!pat
- References: <1992Aug19.234913.622@tfs.com>
- Organization: None
- Lines: 30
-
- eric@tfs.com (Eric Smith) writes:
- |auto String& stringfunction(const String& input)
- |{
- | // Calculate/create a new temporary or named automatic String
- | // and return a reference to it.
- |}
- |
- |The "auto" in the function return value type tells the compiler to allocate
- |the space for that automatic in the stack frame of the caller, instead of
- |the stack frame of the called function.
-
- How is this different from
-
- String stringfunction(const String& input) { /*...*/ }
-
- in the current language? Here I would (naively?) expect the calling
- function to pass the address of a space where the called function
- should construct the result, and that that space will probably be
- in the stack frame of the caller (certainly not in the stack frame
- of the called function, since it must live past the moment when the
- called function returns).
-
- I also don't see how this would make it any easier for the compiler
- to decide when to destroy the object created by the called function
- (if that object is a temporary).
-
- --
- Patrick Smith
- uunet.ca!frumious!pat
- pat%frumious.uucp@uunet.ca
-