next up previous
Next: Unwind/wind protection Up: No Title Previous: Agreement with the

Multiple return values

The call-with-values and values procedures were described in an earlier Scheme of Things ( Lisp Pointers, volume IV, number 1), but I'll review them here. The following is adapted from John Ramsdell's concise description:

Except for continuations created by the call-with-values procedure, all continuations take exactly one value, as now; the effect of passing no value or more than one value to continuations that were not created by call-with-values is unspecified (as indeed it is unspecified now).

values might be defined as follows: =0pt=0pt=0pt =0pt[] (define (values . things) (call-with-current-continuation (lambda (cont) (apply cont things))))

That is, the procedures supplied by call-with-current-continuation must be passed the same number of arguments as values expected by the continuation.

Because the behavior of a number-of-values mismatch between a continuation and its invoker is unspecified, some implementations may assign some specific meaning to such situations; for example, extra values might be ignored, or defaults might be supplied for missing values. Thus this multiple return value proposal is compatible with Common Lisp's multiple values, but strictly more conservative than it. The behavior of programs in such situations was a point of contention among the authors, which is why only the least common denominator behavior was specified.



Margaret M Fleck
Tue Nov 5 21:19:46 CST 1996