Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!usc!zaphod.mps.ohio-state.edu!usenet From: vidynath@function.mps.ohio-state.edu (Vidhyarath K Rao) Newsgroups: comp.theory Subject: Procedures with multiple out parameters: why not? Message-ID: <1990Aug15.231838.5664@zaphod.mps.ohio-state.edu> Date: 15 Aug 90 23:18:38 GMT Sender: usenet@zaphod.mps.ohio-state.edu Organization: Me? Organized? Lines: 55 [Line eaters are extinct, aren't they?] I hope that this is the right newsgroup for this article. I was reading E. Dijkstra, "The humble programmer", Comm ACM 15(1972), pp. 859--866, as reprinted in "Classics in Software Engineering" edited by E. N. Yourdon. I came across the following [para 2 on p. 121 in the reprint]: A number of rules have been discovered, voilation of which will either seriously impair or totally destory the intellectual managebility of the program. These are of two kinds. Those of the first kind ... Examples are the exclusion of the goto-statements and of procedures with more than one output parameter. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ While there is a lot of well-known [i.e. I have heard of them :-^] articles on the goto statement, I have never seen heard of the theoreticians' case against having more than one out parameter. None of the reasons I could think of relates to theory. Can somebody out there give some pointers? Let me list the reasons I came up with for not having it in an existing compiler: 1. It is hard to implement: I do not doubt this: I have heard of functions returning records/structures being implemented in an non-reentrant way. But that does not explain why it shold not be used in psuedo-code or in an ideal language. [In fact R. E. Tarjan uses them in Data Structures and Network Algorithms.] 2. It does not increase efficiency over var parameters in accumulator based machines or in machines with few general purpose registers: This is a practical issue. In any case [using Tarjan's terminology] parameters being modified shold have been initialized, where as parameters being returned need not be. This is useful in lint and its brethern. 3. It does not fit in ``typed Omega calculus'' [I don't know if I can say Lamda calculus here. As far as I know, there is no such thing as Omega calculus.]: Why not get rid of Omega calculus? Is any stronger theory inconsistent? Two further remarks: Firstly, I do not question the fact that having a single return parameter of pre-specified type allows the use of functions in expressions. But why prohibit more than one at all times? Second point, in regard to 3 above: In some otherwise forgettable article in an old issue of BYTE, I saw something to this effect: "Functions can return only a simple value because functions in mathemtatics are required to have a unique result". I immediately performed a gedanken experiment: Go around telling mathemtaicians that they cannot say [in TeX mode] You cannot say things like "Now we will construct a function $f$ from $X$ to $Y \times Z$." At that time I simple chalked it upto the writer's ignorance. But reading the cited article of Dijkstra brought the question again. Eagerly awaiting enlightenment -- Vidhyanth Rao It is the man, not the method, that solves function.mps.ohio-state.edu the problem. - Henri Poincare (614)-366-9341 [as paraphrased by E. T. Bell]