[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Macro question (Guile define-macro)

From: Andreas Rottmann
Subject: Macro question (Guile define-macro)
Date: Tue, 02 Mar 2004 21:22:09 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

The following message is a courtesy copy of an article
that has been posted to comp.lang.scheme as well.


I have a macro problem. I want a macro call 

(condition (&a (b 1) (c 2)) (&x (y z)))

expand into

(%make-compound-condition-helper `((,&a (b 1) (c 2))  (,&x (y ,z))))

I now have the following, which does the job, but I don't like, since
it uses "normal" list construction, while I'd like to have it in the
more concise quasiquote notation:

(define-macro (condition . forms)
  ;; forms: ((type1 (field1 value1) ...) ...)
     (lambda (form)
       ;;(format #t "form ~S\n" form)
        (list 'unquote (car form))
        (map (lambda (entry)
               ;;(format #t "entry ~S\n" entry)
               (list (car entry) (list 'unquote (cadr entry))))
             (cdr form))))

Any help would be greatly appreciated.

Thanks, Andy
Andreas Rottmann         | address@hidden      | address@hidden | address@hidden      | GnuPG Key:
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

Any technology not indistinguishable from magic is insufficiently advanced.
   -- Terry Pratchett

reply via email to

[Prev in Thread] Current Thread [Next in Thread]