[Top][All Lists]

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

Quasi-macros ?

From: Joris van der Hoeven
Subject: Quasi-macros ?
Date: Sun, 9 Feb 2003 20:23:23 +0100 (MET)


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)
       (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 <address@hidden> GNU TeXmacs scientific text editor personal homepage

reply via email to

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