Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!hsi!mfci!m3!genly From: genly@bubble.multiflow.COM (Chris Hind Genly) Newsgroups: comp.lang.icon Subject: var params Message-ID: <1045@m3.mfci.UUCP> Date: 26 Sep 89 18:09:16 GMT Sender: news@mfci.UUCP Distribution: comp Organization: Multiflow Computer Inc., Branford CT Lines: 80 In article <10746@dasys1.UUCP> aj-mberg@dasys1.UUCP (Micha Berger) writes: From: vicc@unix.cie.rpi.edu (VICC Project (Rose)) I too miss var parameters, unfortuanately they require a new data type (to some extent at least) to implement. Thanks for the reply. From: aj-mberg@dasys1.UUCP (Micha Berger) "var" params, as you call it, is normally called "passing by reference. I was being informal here. Either pass by reference or copy-in copy-out would accomplish what I want. Passing by reference is considered by most language feature as dangerous. It allows a function to change the value of a variable without the user realizing. This is an issue of exposition. It is not clear from looking at a call using pass-by-reference that it is actually using pass by reference. One must go to the definition of the procedure being called. Rather than the feature of pass-by-reference being dangerous, this seems to be a weakness in the syntax of a language like Pascal. There is no difference in the syntax between passing an argument by value or by reference. If the syntax were different, anyone reading the source would know that the value of an argument could be changed. As an example, if the values which are to be passed by referenced were followed by an '=', then it would be clear which variables could be changed. In the following example, a could not change value, while b and c could. p(a, b=, c=) If you want to return a bunch of values from one function, why not return a list? This is a matter of clarity and efficiency. I want to be able to express pass-by-reference in the language directly. I don't want to introduce an auxiliary structure like a list, and have to pack it and unpack it. The list has nothing to do with the reason I am writing the program. I don't want to introduce it just to work around the lack of call by reference. From: vicc@unix.cie.rpi.edu (VICC Project (Rose)) One must program ones procedures which use pass by reference such that side effects will be obvious. Agreed. I would be interested in what techniques you've been using to do this. From: ok@cs.mu.oz.au (Richard O'Keefe) 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. I wasn't actually proposing to change the language, but this is along the lines I was thinking. I understand how to work around call-by-value, and I see that its possible to change the translator. But I'm still wondering if people miss the ability to return multiple values from a call. Regardless of the mechanism, either by call-by-reference, copy-in copy-out, or by a multi-valued return value. Do you find you have to return multiple value so few times that its not a problem? Are the icon programs you write so small that you resort to using global variables without trading off understandability? Do you find using an auxiliary structure to pack multiple return values to be unobtrusive? -- ======================================================================= Chris Hind Genly, N1GLZ - Multiflow Computer - mfci!genly (203)488-6090