Hi,

Panicz Maciej Godek <godek.mac...@gmail.com> 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