[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] destructuring-bind?
From: |
Peter Bex |
Subject: |
Re: [Chicken-users] destructuring-bind? |
Date: |
Sun, 4 Feb 2007 22:15:51 +0100 |
User-agent: |
Mutt/1.4.2.2i |
On Sun, Feb 04, 2007 at 04:10:55PM -0500, Elliot Cuzzillo wrote:
> Coming from CL, I'm used to having macro definitions use
> destructuring-bind in their argument lists, so that if we have
> (defmacro blah ((x y) z) ...) then if you call (blah (fee fi) fo) then
> x => fee, y => fi, and z=> fo.
> Does this exist in Chicken's macros, or elsewhere in Chicken?
You can do this with the 'match' macro:
http://galinha.ucpel.tche.br:8080//Pattern%20matching
#;1> (define-macro (foo . bar) (match bar (() 0) ((x) x) (else "sorry")))
#;2> (foo)
0
#;3> (foo "x")
"x"
#;4> (foo "x" "y")
"sorry"
#;5>
HTH,
Peter
--
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
is especially attractive, not only because it can be economically
and scientifically rewarding, but also because it can be an aesthetic
experience much like composing poetry or music."
-- Donald Knuth
pgpB0ZSCymar4.pgp
Description: PGP signature