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

Re: multiple values



So is this a permissible implementation of your proposal?  It seems to me
that it must be since you only try to specify what happens if other than
one value is returned to WITH-VALUES, and nowhere else.

(define magic-multiple-values-marker (list '* 'multiple 'values '*))

(define (values . vals)
  (if (= 1 (length vals))
      (car vals)
      (cons magic-multiple-values-marker vals)))

(define (with-values thunk receive)
  (let ((result (thunk)))
    (if (and (pair? result)
	     (eq? (car result) magic-multiple-values-marker))
	(apply receive (cdr result))
	(receive result))))