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

Re: multiple return values

    If "wrong" doesn't imply "signals an error" then the following is a
    correct implementation of alternative 1.  This is pretty much how the
    feature was implemented in T2.
    (define values-marker (list 'values-marker))
    (define receive-values
      (lambda (thunk proc)
        (let ((vals (thunk)))
          (if (and (pair? vals) (eq? (car vals) values-marker))
    	  (apply proc (cdr vals))
    	  (proc vals)))))
    (define return-values
      (lambda vals
        (cons values-marker vals)))
Not quite a correct implementation, I think.  RETURN-VALUES should
canonicalize single return values:

(define return-values
  (lambda vals
    (if (and (pair? vals) (null? (cdr vals)))
	(car vals)
	(cons values-marker vals))))