Path: utzoo!utgpu!watmath!att!pacbell!ames!indri!uakari.primate.wisc.edu!csd4.milw.wisc.edu!cs.utexas.edu!usc!ucla-cs!rjc From: rjc@maui.cs.ucla.edu (Robert Collins) Newsgroups: comp.lang.c++ Subject: Re: named return values Message-ID: <26302@shemp.CS.UCLA.EDU> Date: 8 Aug 89 22:27:21 GMT References: <1826@cmx.npac.syr.edu> Sender: news@CS.UCLA.EDU Reply-To: rjc@cs.ucla.edu (Robert Collins) Organization: UCLA Computer Science Department Lines: 58 In article <1826@cmx.npac.syr.edu> dl@oswego.edu (Doug Lea) writes: > > >This is an argument for the `official' adoption in C++ of the notion >of named return values, as have been present in GNU g++ for the last >few versions. > >Named return values are a g++ extension that gives a name to the >object returned by a function, in a way vaguely similar to named >return `variables' in Pascal and other languages, but with some >important C++-specific benefits. > [ ... ] >The most practical reason for desiring named return values is >efficiency. Named return values allow one to write a function >returning some large object without also first allocating space for >and creating a local version that is to be somehow built-up solely for >the sake of returning via a copy (i.e., using X(X&)). > [ ... ] >Support? Disagreement? Comments? > I think named returnn values are a great idea. I have been using them since they appeared in g++ (and whined enough to get some of the bugs fixed :-) ). I use them primarily for efficiency. For my particular application, I have seen a 5-10% reduction in run-time. This is a big win, since this application has already run for many hundreds of hours on our Connection Machine. In addition, I find the syntax easy to write and easy to read, and the semantics are clear and easy to understand (at least to me). >Doug Lea, Computer Science Dept., SUNY Oswego, Oswego, NY, 13126 (315)341-2367 >email: dl@oswego.edu or dl%oswego.edu@nisc.nyser.net >UUCP :...cornell!devvax!oswego!dl or ...rutgers!sunybcs!oswego!dl rob collins ------------------------------------------------------------------------------- rjc@cs.ucla.edu C++/Paris on the CM2: The only way to fly. -------------------------------------------------------------------------------