Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!rutgers!columbia!read.columbia.edu!kearns From: kearns@read.columbia.edu (Steve Kearns) Newsgroups: comp.lang.c++ Subject: Re: named return values Summary: yet another argument FOR Message-ID: <6453@columbia.edu> Date: 16 Aug 89 19:57:52 GMT Reply-To: kearns@cs.columbia.edu Organization: Columbia University Department of Computer Science Lines: 19 Here is another argument for named return values. In the olden days, C routines could only return something pointer sized or smaller. (Lets ignore floats!) Later, returning structures was allowed. This is where a basic conceptual mistake was made. C is not a "value" language. Data structures not only have values, they have locations. When routines return small structures we can ignore their location because they can be copied from place to place cheaply. For large objects this is no longer true. EVERY OBJECT RETURNED IS RETURNED TO SOME LOCATION. Therefore the default semantics should allow the programmer access to this location, and the special case should be the small structures for which copying is cheap. Named return values provide this functionality. -steve (kearns@cs.columbia.edu)