[Top][All Lists]

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

macro expand in a specified module

From: Keisuke Nishida
Subject: macro expand in a specified module
Date: Sat, 10 Mar 2001 03:35:31 -0500
User-agent: Wanderlust/2.4.0 (Rio) SEMI/1.13.7 (Awazu) FLIM/1.13.2 (Kasanui) Emacs/21.0.99 (i686-pc-linux-gnu) MULE/5.0 (SAKAKI)

I'd like to expand a macro in a specified module.
The following procedure does it:

  (define (expand e m)
     ((pair? e) (let* ((a (car e))
                       (val (and (symbol? a) (module-ref m a))))
                  (if (defmacro? val)
                      (expand (apply (defmacro-transformer val) (cdr e)) m)
     (#t e)))

  guile> (define-module (foo))
  $1 = #<directory (foo) 80841c0>
  guile> (define-macro (foo x) `(* x x))
  guile> (define-module (bar))
  $2 = #<directory (bar) 8084170>
  guile> (macroexpand '(foo 2))
  $3 = (foo 2)
  guile> (expand '(foo 2) $1)
  $4 = (* x x)

May I add this to ice-9.scm?  I think this procedure looks good
because it is symmetry to eval.


reply via email to

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