Re: Multiple return values

Mark Tillotson <markt@harlequin.co.uk>
25 May 1997 12:44:37 -0400

          From comp.compilers

Related articles
[27 earlier articles]
Re: Multiple return values jamesl@netcom.com (1997-05-08)
Re: Multiple return values hbaker@netcom.com (1997-05-08)
Re: Multiple return values mark@omnifest.uwm.edu (1997-05-13)
Re: Multiple return values bear@sonic.net (Ray Dillinger) (1997-05-13)
Re: Multiple return values jan@fsnif.neuroinformatik.ruhr-uni-bochum.de (Jan Vorbrueggen) (1997-05-14)
Re: Multiple return values hbaker@netcom.com (1997-05-14)
Re: Multiple return values markt@harlequin.co.uk (Mark Tillotson) (1997-05-25)
Re: Multiple return values hbaker@netcom.com (1997-05-25)
Re: Multiple return values jmccarty@sun1307.spd.dsccc.com (1997-05-30)
| List of all articles for this month |

From: Mark Tillotson <markt@harlequin.co.uk>
Newsgroups: comp.compilers,comp.lang.misc
Date: 25 May 1997 12:44:37 -0400
Organization: Harlequin Ltd, Longstanton House, Cambridge UK
References: 97-04-091 97-04-112
Keywords: design

marssaxman < (Mars Saxman) marssaxman%sprynet.com.antispam@nac.no> wrote:
> I think it is an artefact of the origin of the "function" concept. The
> idea of a function in maths is that you give it some parameters and it
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> performs some calculation on them. The result of the calculation is
> the return value. It doesn't make sense to have, for example, an
> arctangent return more than one value. Given the origins of computing
> in maths it is easy to see why this habit has been carried on.


Huh? Mathematically a function is simply a many-1 binary relation
defined for the whole of its domain. Any talk of more than one
argument is shorthand for using cartesian products, which you can do
with the result just as easily. In fact functions really don't have
anything to do with calculation!!


Conceptually there should be no difference between passing arguments
and passing results, because a value is being passed, and hopefully
the type passed is a subtype of the value expected. Multiple args and
results are shorthand for cartesian products.


I suspect that the reason languages quickly adopted multiple args yet
retained single results is both the prior use of shorthand convention
in maths, and because that in order to live with a world where
functions take a "single argument" you either need an explicit
cartesian product operation, which itself is written as a function of
more than one argument, or you need to support higher-order functions,
which implies implementing closures and using garbage collection.


The implementors of Fortran didn't, it seems, want to implement
closures and curried functions, and set a(n) historical precedent.


__Mark
[ markt@harlequin.co.uk | http://www.harlequin.co.uk/ | +44(0)1954 785433 ]
[I suspect that Fortran allowed multi-argument functions because they wanted
to put two-argument arctangent in the library. -John]


--


Post a followup to this message

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