Xref: utzoo comp.theory:1027 comp.lang.functional:422 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!mips!pacbell.com!pacbell!osc!jgk From: jgk@osc.COM (Joe Keane) Newsgroups: comp.theory,comp.lang.functional Subject: Re: Why not multiple out parameters? [again] Keywords: aliasing Message-ID: <3788@osc.COM> Date: 11 Sep 90 09:44:45 GMT References: <1990Aug28.203643.11214@zaphod.mps.ohio-state.edu> <4019@rex.cs.tulane.edu> <2501@l.cc.purdue.edu> <4060@rex.cs.tulane.edu> <3352@stl.stc.co.uk> Reply-To: jgk@osc.COM (Joe Keane) Followup-To: comp.theory Organization: Versant Object Technology, Menlo Park, CA Lines: 26 I think returning a record just gets around the issue. We don't use a single record to pass all the in parameters to a function, so why should we do it for out parameters? The original `problem' with multiple problems was really with pointer aliasing, or more generally, modifier aliasing. If objects are returned, there is no possibility of conflict. The caller may actually allocate space on the stack for the returned objects, but this is an implementation issue and there is still no possibility of conflict. There are two ways to deal with aliased modifiers. One way is to say that the modifications are actually sequential. Therefore, if two modifications are done to the same object, one of the modifications is lost, or at least doesn't determine the most current version. The order may be pre-defined, so say the textually earlier parameter is the one that is lost. Or the order may be undefined, so that which ever modifier gets there first loses. The other way is to insist that the modifications are done together, which is more like what we'd expect in a functional language. Then each expression which writes a return value expects to be the last one before the function exits. This works fine as long as they don't both want to write to the same place. What happens if they are aliases? In that case each one has to go before the other. Therefore the problem is deadlock. This makes sense if you think about it; the two problems are really closely related. Two modifiers want exclusive rights to determine a single value, the current state of the returned object. They can't both have it.