Is there an equivalent to macroexpand or macroexpand-1 for parenscript macros? Doing (ps (some macro expression))
will display the generated javascript, but there are times when it would be nice to see the parenscript just before it gets converted to javascript.
Asked
Active
Viewed 178 times
5

BnMcGn
- 1,440
- 8
- 22
-
1Hm, you could define the macro as (non parenscript, normal lisp) macro and macro expand it the usual way. I guess that this *should* work for many cases, but it's of course only a hack. – Daniel Jour Nov 26 '15 at 12:59
1 Answers
5
In parenscript's compiler.lisp
file, there are the functions
ps-macroexpand-1
and ps-macroexpand
. Unfortunately, they are not exported by the parenscript package. You can call them anyway using a double colon.
For example,
(defpsmacro aif (test true &rest false)
`(let ((it ,test))
(if it ,true ,@false)))
(ps::ps-macroexpand-1 '(aif 3 it))
;;=>
(LET ((IT 3))
(IF IT
IT))
T

Riley
- 982
- 1
- 7
- 19