Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!udel!princeton!news.princeton.edu!blume
From: blume@atomic.cs.princeton.edu (Matthias Blume)
Subject: Re: multiple Return values
In-Reply-To: four@owlnet.rice.edu's message of 27 Jan 1995 00:34:47 GMT
Message-ID: <BLUME.95Jan27111803@atomic.cs.princeton.edu>
Originator: news@hedgehog.Princeton.EDU
Sender: news@Princeton.EDU (USENET News System)
Nntp-Posting-Host: atomic.cs.princeton.edu
Organization: Princeton University
References: <3g9f37$nqt@larry.rice.edu>
Date: Fri, 27 Jan 1995 16:18:03 GMT
Lines: 41

In article <3g9f37$nqt@larry.rice.edu> four@owlnet.rice.edu (Sebastian Erich Good) writes:

   [ a whole lot about how multiple return values could stand for
     *several* of the argument of another function call at once ]

At a first glance this idea seems to have its merits.  However, I can
see some serious problems with it.  Let me skip the discussion of how
this can or cannot be compiled very efficiently (somebody said this
argument doesn't count... :).

From a language-designed point of view I find it already regretful,
that at the site of the function invocation you have to remember,
which order the functions expects its arguments in.  This is a common
problem in almost all languages which allow multiple arguments,
because almost all languages address their function arguments by
position.  Strong typechecking, which we don't even have in Scheme,
can help a little bit, but it doesn't help in cases, where adjacent
arguments of equal type are accidentially switched around.

In some languages (SML, for example), you can pass named arguments.
There is no danger of mixing them up, but this comes at the expense of
more verbosity.

Now, with multiple return values which automagically spread themselves
over a given argument list things become much worse:  You not only
have to remember the order of the arguments, you now also have to
remember the number of values other functions return, and their order
too. Imagine the complications if the order of values returned doesn't
match the order of arguments expected!

Quickly this gets very confusing.  Just think about functions the
number of values they return depends on run-time variables!

[BTW, this is also what I see as the major difficulty for a compiler.
While we only need soft typing or other kinds of global analyses in
order to get a first-class values/call-with-values fast (while other
parts of the language remain unaffected), we would need this kind of
compiler trickery to make *anything* run at more than snail-pace.]

--
-Matthias
