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

multiple values and call/cc.

>> From: mkatz@sesame.stanford.edu (Morris Katz)
>> 	   (with-values 
>>              (call-with-current-continuation
>>               (lambda (c)
>>                (set! cont c)
>>                (values 1 2)))
>>              cons)

I do not understand your example.  It seems to me the generator does
not evaluate to a procedure applicable to zero arguments.  Independent
of the example, I think I get your point.  What the proposal should
say is that values could be defined as:

	(define (values . args)
	    (lambda (cont) (apply cont args))))

and with-values creates a continuation with arity exactly matching the
arity of the receiver.  The arity of ordinary continuations is to be
left unspecified.  So let me try one more time.


(values obj ...)                                        essential procedure

Applies the current continuation to 0 or more values.  It is used to
return multiple values (see with-values).  Values could be defined as:
	(define (values . args)
	    (lambda (cont) (apply cont args))))

(with-values generator receiver)      			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.
Within procedure 'generator', the initial escape procedure returned by
call-with-current-continuation is 'receiver'.

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

          (lambda ()
	      (lambda (k) 
		(k 1 2))
	  cons)   	      =>              (1 . 2)


Notice that the discussion of the arity of ordinary continuations must
be moved to the section describing call-with-current-continuation.  I
have yet to draft any text, but I have not forgotten the problem.