unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Quasi-macros ?
@ 2003-02-09 19:23 Joris van der Hoeven
  2003-02-10 16:33 ` david
  0 siblings, 1 reply; 2+ messages in thread
From: Joris van der Hoeven @ 2003-02-09 19:23 UTC (permalink / raw)



Hi,

Consider the following piece of code:

  (define (define-table-decls name l)
    (if (null? l) l
        (cons `(hash-set! ,name ',(caar l) ',(cadar l))
  	      (define-table-decls name (cdr l)))))

  (define-macro (define-table name . l)
    `(begin 
       (define ,name (make-hash-table ,(+ (* (length l) 2) 1)))
       ,@(define-table-decls name l)))

  (define-table test
    (hello hoi)
    (joke grapje)
    (gnu blauwbilgorgel))

This allows you to define many tables in a nice way.
Sometimes however, it would be nice to write things like

  (define-table the-question
    (two ,(+ 1 1))
    (four ,(* 2 2)))

Someone has an idea of how to do this *without* explicitly
using 'eval', which might result in loosing the context?

Thanks, Joris


-----------------------------------------------------------
Joris van der Hoeven <vdhoeven@texmacs.org>
http://www.texmacs.org: GNU TeXmacs scientific text editor
http://www.math.u-psud.fr/~vdhoeven: personal homepage
-----------------------------------------------------------



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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-02-10 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-09 19:23 Quasi-macros ? Joris van der Hoeven
2003-02-10 16:33 ` david

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