[racket-dev] for/first and multiple values

From: Carl Eastlund (cce at ccs.neu.edu)
Date: Sun Aug 29 20:27:59 EDT 2010

What do you propose for/first should return if the set s is empty?  It
will be somewhat difficult to make it divine that it ought to return
two values.  Perhaps, if this feature is adopted, for/first should
allow a #:default keyword to specify the return value if no elements
crop up, so you can put in the right number of values.

Carl Eastlund

On Sun, Aug 29, 2010 at 8:21 PM, David Van Horn <dvanhorn at ccs.neu.edu> wrote:
> Why is the body of a for/first a single valued context?  I would expect this
> to work:
>
>  (let ((s (set 1 3 10)))
>    (for/first ((x (in-set s)))
>      (values x (set-remove s x))))
>
> But I get:
>
>   context expected 1 value, received 2 values: 1 (set 3 10)
>
> (By the way, this operation would be nice to have in racket/set.)
>
> David


Posted on the dev mailing list.