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

Multiple values for R4RS.



Maybe there is enough consensus to allow agreement on the
non-controversial aspects of multiple values for R4RS.  What do people
think about adding only VALUES and APPLY-VALUES?

-----------------Adapted from Mike Shaff <shaff@sesame.stanford.edu>.

(values obj ...)                                        essential procedure

Returns 0 or more values to a receiving procedure (See apply-values).

        (values)        =>              returns zero (no) values

        (values 1)      =>              returns a single value, 1

        (values 1 'a) 	=>              returns two values, 1 and the symbol a


(apply-values receiver generator)      			essential procedure

Returns the result of applying the procedure 'receiver' to the values
produced by calling procedure 'generator' with no arguments.  It is an
error if 'receiver' cannot be applied to the number of values returned
by 'generator' or if 'generator' cannot be called with zero arguments.

        (apply-values cons
               (lambda ()
                 (values 1 2)))         =>              (1 . 2)

--------------------------------

Note:  I think a useful extension of apply-values is

(apply-values receiver generator . generator-args)

Returns the result of applying the procedure 'receiver' to the values
produced by calling procedure 'generator' with 'generator-args'.  It
is an error if 'receiver' cannot be applied to the number of values
returned by 'generator' or if 'generator' cannot be called with the
number of values in 'generator-args'.


John