[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] what happened to define-structure in the pattern mat
From: |
felix winkelmann |
Subject: |
Re: [Chicken-users] what happened to define-structure in the pattern matching module? |
Date: |
Mon, 30 May 2005 10:35:15 +0200 |
On 5/30/05, Michele Simionato <address@hidden> wrote:
> (define-structure (name fields)) used to work, but now I get an error.
> I like structures of the pattern matching module, since they are just
> vectors and I can match them pretty easily. Can I have them back?
You can match structures defined with `define-record' or
`define-record-type' with the `($ ...)' pattern:
#;1> (define-record-type foo (make-foo a b) foo? (a get-a) (b get-b))
#;2> (match (make-foo 99 100) (($ foo x y) (list x y)))
(99 100)
#;3> ,x (match (make-foo 99 100) (($ foo x y) (list x y)))
(let ((g10 (make-foo 99 100)))
(if (foo? g10)
((lambda (x y) (list x y)) (##sys#block-ref g10 1) (##sys#block-ref g10 2))
(##sys#match-error g10)))
#;3>
cheers,
felix