This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Tuple types
- To: guile at sourceware dot cygnus dot com
- Subject: Re: Tuple types
- From: Jorgen 'forcer' Schaefer <forcer at mindless dot com>
- Date: 23 Apr 2000 18:09:01 +0200
- References: <x7bt31nfy7.fsf@benten.tomobiki.it>
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"))