guile-user
[Top][All Lists]
Advanced

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

Re: Expanding macros


From: Ludovic Courtès
Subject: Re: Expanding macros
Date: Wed, 26 Sep 2012 23:54:46 +0200
User-agent: Gnus/5.130005 (Ma Gnus v0.5) Emacs/24.2 (gnu/linux)

Hi,

Panicz Maciej Godek <address@hidden> skribis:

> is there any legitimate way to expand the scheme macros
> to the scheme code in guile 2.0?
> The macroexpand procedure seems only to compile the code
> to the tree-il language (no matter whether 'e, 'c or any other
> symbol is passed as a second argument):
>
> (macroexpand '(define (f a b) (list a b)) 'e)
> ; ===> #<tree-il (define f (lambda ((name . f)) (lambda-case (((a b)
> #f #f #f () (a-4236 b-4237)) (apply (toplevel list) (lexical a a-4236)
> (lexical b b-4237))))))

There’s the ,expand command at the REPL.

It’s implemented like this:

  (define (repl-expand repl form)
    (let ((from (repl-language repl))
          (opts (repl-compile-options repl)))
      (decompile (compile form #:from from #:to 'tree-il #:opts opts
                          #:env (current-module))
                 #:from 'tree-il #:to from)))

Psyntax, the macro expander, returns tree-il, hence the need to go
through ‘decompile’.

Thanks,
Ludo’.




reply via email to

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