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

multiple return values

    Date: 27 Mar 87 15:47:06 PST (Fri)
    From: willc%tekchips.tek.com at RELAY.CS.NET

        single: (E --> C) --> K

     1. single = \ f e* . # e* = 1 --> f (e* ! 1), wrong "..."

     2. single = \ f e* . # e* >= 1 --> f (e* ! 1), wrong "..."

     3. single = \ f e* . # e* >= 1 --> f (e* ! 1), f unspecified

I have already put in my vote for 1.

    I see no way to implement the proposed procedures in R3RS Scheme, but
    most implementations should find it easy to add them.

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)))

I think that the fact that this is so easy is a significant reason to
favor alternative 1.


I find the feature to be pretty unuseable unless there is some
syntactically sugared way to use RECEIVE-VALUES (viz. T's RECEIVE
and CL's MULTIPLE-VALUE-BIND), but maybe this issue can be argued