Re: Multiple return values

fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
18 Apr 1997 01:04:45 -0400

          From comp.compilers

Related articles
Multiple return values Arthur.Chance@Smallworld.co.uk (1997-04-16)
Re: Multiple return values WStreett@shell.monmouth.com.spamguard (1997-04-18)
Re: Multiple return values smryan@mail.com (1997-04-18)
Re: Multiple return values icedancer@ibm.net (1997-04-18)
Re: Multiple return values hbaker@netcom.com (1997-04-18)
Re: Multiple return values fjh@mundook.cs.mu.OZ.AU (1997-04-18)
Re: Multiple return values (Mars Saxman) marssaxman%sprynet.com.antispam@nac (marssaxman) (1997-04-18)
Re: Multiple return values preston@tera.com (1997-04-18)
Re: Multiple return values jbuck@Synopsys.COM (1997-04-18)
Re: Multiple return values smryan@mail.com (1997-04-20)
Re: Multiple return values danwang@dynamic.CS.Princeton.EDU (1997-04-20)
Re: Multiple return values smcadams@sprynet.com (steve mcadams) (1997-04-20)
[24 later articles]
| List of all articles for this month |

From: fjh@mundook.cs.mu.OZ.AU (Fergus Henderson)
Newsgroups: comp.compilers,comp.lang.misc
Date: 18 Apr 1997 01:04:45 -0400
Organization: Comp Sci, University of Melbourne
References: 97-04-091
Keywords: design

Arthur.Chance@Smallworld.co.uk (Arthur Chance) writes:


>Most programming languages allow procedures with multiple arguments
>(in some cases allowing them to be used in curried form as well), but
>very few languages allow multiple return values, in spite of the fact
>that multiple results *are* multiple arguments when you're wearing
>CPS-tinted glasses. Why is this?


Many if not most programming languages allow procedures with
multiple output arguments. For example, instead of


(x, y) = foo(a, b);


in C you can write


foo(a, b, &x, &y);


and in C++ or Ada you can write


foo(a, b, x, y);


and (at least to a first approximation) this is no less convenient.


Return values only provide syntactic convenience over and above
output arguments in the single return value case, when you can
avoid naming the result. For example,


bar(baz(a));


is more convenient than


int tmp;
baz(a, &tmp);
bar(tmp);


But in the multiple return value case, you're going to have to name
the argument values anyway. Thus allowing multiple return values
doesn't seem to buy you much over allowing output arguments.


(Note that I'm not saying that allowing multiple return values is
necessarily a bad idea, I'm just giving my guess as to the reasons
for the historical data you observed.)


--
Fergus Henderson <fjh@cs.mu.oz.au>
WWW: <http://www.cs.mu.oz.au/~fjh>
PGP: finger fjh@128.250.37.3
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.