[plt-scheme] Why multiple values?

From: Ittai Balaban (balaban at cs.nyu.edu)
Date: Sun Dec 24 19:03:05 EST 2006

Hi.

On Sun, 2006-12-24 at 15:36 -0800, Danny Yoo wrote:

> > (define-syntax first-two
>      (syntax-rules ()
>        [(_ expr)
>         (call-with-values (lambda () expr)
>                           (lambda args (list (first args)
>                                              (second args))))]))

Wouldn't you prefer

(define-syntax first-two
   (syntax-rules ()
     [(_ expr)
      (call-with-values (lambda () expr)
                        (lambda args (values (first args)
                                             (second args))))]))

Usage then becomes, e.g.,

> (define-values (x y) (first-two (values 1 2 3 4 5)))

-- 
Ittai




Posted on the users mailing list.