[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Multiple Value Return and Continuation Passing Style

I guess it's worth noting just for completeness that there is an alternative
to the multiple-value-return idea which is suggested by continuation-passing
style a la Sussman/Steele papers... I take no stand on whether this would be
the right thing for Common-Lisp, but I point it out for completeness since
it involves no pervasive effect upon the whole interpreter to implement things
in this style. Here's an example from the preliminary T manual (May '82):

    (DIV2 n1 n2 proc)

     Division yielding quotient and remainder. Not yet implemented. The
     PROC should be a procedure of two arguments; it will be invoked on
     the quotient and remainder. For example:

      (DIV2 11 4 LIST)  => (2 3)
      (DIV2 11 4 PROJ0) => 2

Where PROJ0 is like the subr version of BLOCK0 (which is T's name for PROG1).

This is upward compatible with the LispM in that although it doesn't use 
multiple values at all, it can be implemented by taking advantage of 
functions that return them. eg, a sample LispM implementation would be:

       (QUOTIENT X Y)
     (FN QUO REM)))

Also, remember that constructs like:


where (G) might return multiple values can always be re-written if G can
be made to accept a continuation arg as something like:


The intent here is not to say this is what we should do, but just to make
sure we're not overly restricting our mode of thinking in this issue...