How are vector patterns used in syntax-rules?

Posted by Jay on Stack Overflow See other posts from Stack Overflow or by Jay
Published on 2010-03-26T21:11:01Z Indexed on 2010/03/26 21:13 UTC
Read the original article Hit count: 346

Hi,

I have been writing Common Lisp macros, so Scheme's R5Rs macros are a bit unnatural to me. I think I got the idea, except that I don't understand how one would use vector patterns in syntax-rules:

(define-syntax mac
  (syntax-rules ()
    ((mac #(a b c d))
     (let ()
       (display a)
       (newline)
       (display d)
       (newline)))))

(expand '(mac #(1 2 3 4)))  ;; Chicken's expand-full extension shows macroexpansion

=> (let746 () (display747 1) (newline748) (display747 4) (newline748))

I don't see how I'd use a macro that requires its arguments to be written as a vector:

(mac #(1 2 3 4))
=>
1
4

Is there some kind of technique that uses those patterns?

Thank you!

© Stack Overflow or respective owner

Related posts about lisp

Related posts about Scheme