Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!news.sei.cmu.edu!cis.ohio-state.edu!math.ohio-state.edu!howland.reston.ans.net!spool.mu.edu!news.cs.indiana.edu!jashley@cs.indiana.edu
From: "J. Michael Ashley" <jashley@cs.indiana.edu>
Subject: Re: Multiple values
Message-ID: <1994Oct3.142014.3538@news.cs.indiana.edu>
Organization: Computer Science, Indiana University
References: <g2mgTc2w165w@sytex.com> <hbakerCwyEwq.AJB@netcom.com>
Date: Mon, 3 Oct 1994 14:20:09 -0500
Lines: 38

hbaker@netcom.com (Henry G. Baker) writes:
>>        Any advice/pointers to literature available on 
>>efficiently implementing CL multiple values?  I've
>>...

>I seem to recall that some of the folks at the University of Indiana
>have written papers about efficient multiple values in Scheme.  Sorry
>I don't have any references.

That's Indiana University.  Kent Dybvig and I wrote a paper on
implementing Scheme multiple values that was presented at LFP.  We
also discussed how our mechanism could be adapted to Common Lisp.  Our
conclusion was that the easiest and probably best solution for Common
Lisp is to pass return values in the same locations as argument values
(registers, frame, whereever) and to always set a register to the
number of return values.  This burdens ordinary (single-value) returns
slightly, but only slightly and in some cases not at all if the
instruction to set the register can be placed in an otherwise
unoccupied delay slot.  This count can then be used as the argument
count in a simple multiple-value call (one with only one producer) or
to form the aggregate argument count in a more complicated multiple
value call.  For multiple-value-bind it can be used to dispatch into a
series of nil-loads for missing values.  The zero-value return code
should also arrange to place nil into the first argument location so
that single-value call sites need never check the number of values
returned.

Our solution for Scheme involves multiple return points.  It is a bit
more complicated since we want to signal an error whenever an
unexpected number of values is returned.  The primary benefit of our
solution is that the necessary error checking is free in the common
cases.  Common Lisp, on the other hand, requires the implementation to
silently discard or conjure up values as needed.  Our mechanism may
still be marginally faster for Common Lisp, since we eliminate the
need for the register assignment on single-value returns, but this
small benefit is probably not worth the added complexity.

Mike
