[comp.lang.functional] Why not multiple out parameters? again

jgk@osc.COM (Joe Keane) (09/11/90)

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.

news@usc.edu (09/12/90)

In article <3788@osc.COM> jgk@osc.COM (Joe Keane) writes:

   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?

What's wrong with getting around the issue?

I can see the need for having two "in parameters" (otherwise, joining
hitherto distinct pieces of information is akward), but I fail to see
the need for multiple "out parameters" in a functional language.
Excuse me for being dense, but what is the range?

If you need to do something on the order of passing different pieces
of information (about some core datum) to multiple function
applications, the proper way would seem to be to construct some
derived function which applies the base functions properly.  (e.g.
J's conjunctions)