Arc Forumnew | comments | leaders | submitlogin
How do you see what a macro expands to?
2 points by lark 3319 days ago | 6 comments
I tried the following but the output is horrifying.

  arc> (macex '(mac test a `(list ,a)))
  ((fn () (sref sig (quote a) (quote test)) (safeset test (annotate (quote mac) (fn a (quasiquote (list (unquote a))))))))
How can I get back something as simple as:

  (list a)


5 points by Pauan 3319 days ago | link

First off, you're seeing the macro-expansion of the "mac" macro, not the macro-expansion of the "test" macro. Try this instead:

  arc> (mac test a `(list ,a))
  arc> (macex '(test a))
Secondly, you can also use "macex1" to only expand it one time:

  arc> (macex1 '(mac test a `(list ,a)))
Sometimes this produces nicer output.

-----

3 points by jsgrahamus 3318 days ago | link

Why does your example return (list (a)) instead of (list a)?

Steve

-----

3 points by akkartik 3318 days ago | link

Rest arg :)

-----

2 points by jsgrahamus 3317 days ago | link

???

-----

3 points by akkartik 3317 days ago | link

  (mac test a `(list ,a))
vs

  (mac test (a) `(list ,a))
Does that help?

-----

3 points by lark 3319 days ago | link

Thank you.

-----