[Prev][Next][Index][Thread]
Re: small Q
Brian Campbell wrote:
>
> Since I'm comming from a long history of one return value programming
> languages (Scheme R4RS, SmallTalk, C, Java, PASCAL, etc.), could someone
> describe where multiple return values would be useful and not just a
> convenience?
A couple of other examples: whole number division might return quotient
and remainder. Matrix inversion could return the inverse and
determinant. An equation solver could return multiple roots.
All these can be obviously be done by returning lists too, but then one
has to write access code to split up the list again. Besides being hard
to read, this also thwarts flow analysis somewhat.
Multiple return values seem as natural a thing to have as multiple
arguments.
In fact, it occurs to me that a nice extension to the language would be
to allow more than two procedures in call-with-values - each procedure's
(values ..) form would supply arguements to the procedure to its right,
forming a kind of pipeline. It would certainly be easier to read than
the normal composition of nested function calls.
Follow-Ups:
References: