This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
question about define-syntax
- From: Yaroslav Kavenchuk <kavenchuk at gmail dot com>
- To: kawa <kawa at sourceware dot org>
- Date: Fri, 08 Feb 2008 13:59:52 +0200
- Subject: question about define-syntax
The simplified example:
;; convert list to list of pairs
(define-syntax make-pair-list
(syntax-rules ()
((_ any)
(error "Broken arguments count for pair-list"))
((_ name value)
(cons (cons name value) ()))
((_ name value . args)
(cons (cons name value) (make-pair-list . args)))))
;; call function with list of pairs
;; this is wrong:
(define-syntax func-with-pairs
(syntax-rules ()
((_ func . args)
(func . (make-pair-list . args)))))
;; result of (func-with-pairs list 1 2 3 4)
;; is (#<macro make-pair-list> 1 2 3 4), not ((1 . 2) (3 . 4))
;; this is right
(define-syntax func-with-pairs
(syntax-rules ()
((_ func . args)
(apply func (make-pair-list . args)))))
;; but why need `apply`?
How write macro without `apply`?
Thanks!
--
WBR, Yaroslav Kavenchuk.