unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Macro question (Guile define-macro)
@ 2004-03-02 20:22 Andreas Rottmann
  0 siblings, 0 replies; only message in thread
From: Andreas Rottmann @ 2004-03-02 20:22 UTC (permalink / raw)


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         | Rotty@ICQ      | 118634484@ICQ | a.rottmann@gmx.at
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


_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-03-02 20:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-03-02 20:22 Macro question (Guile define-macro) Andreas Rottmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).