Re: Multiple return values

jens.hansson@mailbox.swipnet.se (Jens Hansson)
4 May 1997 22:40:28 -0400

          From comp.compilers

Related articles
[20 earlier articles]
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)
Re: Multiple return values hbaker@netcom.com (1997-05-14)
[3 later articles]
| List of all articles for this month |

From: jens.hansson@mailbox.swipnet.se (Jens Hansson)
Newsgroups: comp.compilers,comp.lang.misc
Date: 4 May 1997 22:40:28 -0400
Organization: -
References: 97-04-091 97-04-109
Keywords: design

fjh@mundook.cs.mu.OZ.AU says...
>... 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.


In my opinion there is a great difference in readability of the code.
In the multiple-return example you directly see which values are input
to the function and which are output, especially as compared to the
C++ example. In C++, Pascal, Ada, Basic or whatever you need to see
the subprogram declaration to be able to determine what it is doing.


Normally there are three different kinds of parameters. With Ada
terminology: in out and inout (a fourth would be "notused"...:-) Let
me suggest a new notation for these parameter types:


      (out1,out2, ...outn) = (ref1,ref2,...refn).func(in1,in2,...inn)


This syntax would immediately show which values are parameters, return
values and "side-effects". It is also (with a slight change of
semantics) backward compatible with the popular dot-notation for
calling OO methods when we have only one inout parameter.


Comments?


--Jens
[Looks like Perl. -John]


--


Post a followup to this message

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