guile-user
[Top][All Lists]
Advanced

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

Re: values->list elements


From: szgyg
Subject: Re: values->list elements
Date: Tue, 13 Jun 2006 19:20:47 +0200
User-agent: Thunderbird 1.5 (Windows/20051201)

Jon Wilson wrote:
Is there any sensible way to implement the following semantics:

(+ (values 1 2))
==>
3
>
Or perhaps with a macro of some sort (but preferably as above)...

(+ (values->list-elements (values 1 2)))
==>
3

! untested code !

(define-macro (values->list vs)
   `(call-with-values (lambda () ,vs) list))

(apply + (values->list (values 1 2 3)))

or

(define-macro (make-cockeyed-function f)
   `(lambda (vs) (apply ,f (values->list vs))))

((make-cockeyed-function +) (values 1 2 3))

The intermediate step (after the macro expansion I guess) would look like

(+ 1 2)

No, this is impossible without redefining +. A macro produces 1 sexp, not more.

It seems like this would make multiple values much much more useful.

szgyg

ps: GNU Free Software Directory list guile-1.6.7 as recent




reply via email to

[Prev in Thread] Current Thread [Next in Thread]