Re: Multiple return values

tim@franck.Princeton.EDU (Tim Hollebeek)
4 May 1997 22:15:20 -0400

          From comp.compilers

Related articles
[19 earlier articles]
Re: Multiple return values albaugh@agames.com (1997-04-22)
Re: Multiple return values tiggr@es.ele.tue.nl (1997-04-30)
Re: Multiple return values jch@hazel.pwd.hp.com (John Haxby) (1997-05-04)
Re: Multiple return values jan@digicomp.com (Jan Galkowski) (1997-05-04)
Re: Multiple return values gscase@interact.net.au (1997-05-04)
Re: Multiple return values Robert.Harley@inria.fr (1997-05-04)
Re: Multiple return values tim@franck.Princeton.EDU (1997-05-04)
Re: Multiple return values jens.hansson@mailbox.swipnet.se (1997-05-04)
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)
[4 later articles]
| List of all articles for this month |

From: tim@franck.Princeton.EDU (Tim Hollebeek)
Newsgroups: comp.compilers,comp.lang.misc
Date: 4 May 1997 22:15:20 -0400
Organization: Princeton University
References: 97-04-091 97-04-112 97-04-135
Keywords: syntax, design



(Mars Saxman) marssaxman@sprynet.com writes:
> 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.


Pieter Schoenmakers <tiggr@es.ele.tue.nl> wrote:
>What about a function R x R -> R x R?


Most mathematicians would contend that this returns a single value,
and that value is an ordered pair of real numbers. Of course,
multiple arguments are just a convenience anyway; one could do just
fine talking about f((a,b,c)) instead of f(a,b,c). The situation is
really symmetric wrt inputs and outputs (especially for relations of
which functions are just a special case); it is the typical
mathematical and PL notation that makes them look different.


IMO, the ideal syntax is:


f(a, b, c) -> (c, d)


though many people prefer assignment-type syntax. The advantage is
that:


f(a) -> a


makes sense read left to right, while:


a := f(a)


looks suspiciously recursive. Using '=' for assignment qualifies as
"not even wrong", IMNSHO :-)


--
Tim Hollebeek
Electron Psychologist
Princeton University
email: tim@wfn-shop.princeton.edu
--


Post a followup to this message

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