Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwm.edu!uakari.primate.wisc.edu!ames!uhccux!munnari.oz.au!cs.mu.oz.au!ok
From: ok@cs.mu.oz.au (Richard O'Keefe)
Newsgroups: comp.lang.icon
Subject: Re: var params
Message-ID: <2174@munnari.oz.au>
Date: 23 Sep 89 10:52:23 GMT
References: <1027@m3.mfci.UUCP> <10746@dasys1.UUCP>
Sender: news@cs.mu.oz.au
Distribution: comp
Lines: 35

[I've lost the original context]
In article <10746@dasys1.UUCP>, aj-mberg@dasys1.UUCP (Micha Berger) writes:
> "var" params, as you call it, is normally called "passing by reference.

If you will be content with pass by value result (as Fortran and Ada are),
you can get that effect just by bending the Icon translator.  Suppose, for
example, that you add Ada syntax for arguments:
	'in'		value passed in
	'out'		result passed back
	'in out'	value passed in and result passed back.
A procedure definition like
	procedure foo(in x, out y, in out z)
	...
	end
could be translated as

	procedure foo(x, OUTARGS)
		use OUTARGS[1] wherever y appears
		use OUTARGS[2] wherever z appears
	end

A call
	foo(eks, out wye, in out zed)
would then be translated as
	temp := [&null, zed];
	foo(eks, temp);
	wye := temp[1], zed := temp[2]

This gets a wee bit tricky if wye and zed are expressions, but Icon
already has the machinery to represent "references" so that procedure
calls can be used on the left hand side of := .

This looks as though it should work, and it seems like a better idea to
just bend the translator than to hack the low level stuff -- more portable
if you do it right.  And you'll have to bend the translator anyway.