This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Tuple types


Diego Dainese <ddainese@dsi.unive.it> writes:

> My idea is to define a 'let'-like special form that permit more that
> one variable name in a single binding, and if so unpack the init
> argument that must be of type tuple; in example:
> 
>     (let-tuple* ((tup (tuple 1 "pippo"))
>                  (num name tup))
>       (display num)
>       (display name))

Check SRFI 8: RECEIVE: Binding to multiple values,
http://srfi.schemers.org/.

Your code would be

(receive (num name) (values 1 "pippo")
  (display num)
  (display name))

and all it takes is this simple syntax:

(define-syntax receive
  (syntax-rules ()
    ((receive formals expression body ...)
     (call-with-values (lambda () expression)
                       (lambda formals body ...)))))

HTH,
        -- forcer

-- 
((email . "forcer@mindless.com")       (www . "http://forcix.cx/")
 (irc   . "forcer@#StarWars (IRCnet)") (gpg . "/other/forcer.gpg"))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]