guile-user
[Top][All Lists]
Advanced

[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.

Hi!

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) ...) ...)
  (list
   '%make-compound-condition-helper
   (list
    'quasiquote
    (map
     (lambda (form)
       ;;(format #t "form ~S\n" form)
       (cons
        (list 'unquote (car form))
        (map (lambda (entry)
               ;;(format #t "entry ~S\n" entry)
               (list (car entry) (list 'unquote (cadr entry))))
             (cdr form))))
       forms))))

Any help would be greatly appreciated.

Thanks, Andy
-- 
Andreas Rottmann         | address@hidden      | address@hidden | address@hidden
http://yi.org/rotty      | GnuPG Key: http://yi.org/rotty/gpg.asc
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]