Lisp HUG Maillist Archive

More portable macroexpand-all without needing augment environment


I figure this group is the one most likely to be interested in
this. Sorry if it's off topic. Is there anywhere better?

In my battles with cl-cont (a CPS transformer), to try to get it to be (1)
correct, (2) not horribly inefficient, I came across read
"Macroexpand-All: An example of a Simple Lisp Code Walker" by Richard
Waters <http://www.merl.com/papers/TR93-17/>

It occurred to me that another approach to macroexpansion would be more
portable, namely to transform the code itself with macros so that it
returns a quoted version of itself after macroexpansion (expansion of
all macrolets and symbol-macrolets). This avoids the need for explicitly
implementing an augment environment function.

As far as I know, there is no other tool for expanding all macrolets? (A
feature I've very often wanted and should be immensely helpful for
debugging.)

The code is at http://paste.lisp.org/display/83349 for now; I just
wrote it today and while I think it is complete (works on Lispworks,
Allegro, SBCL and ClozureCL) there will inevitably be bugs.

For an example of it working correctly (I hope),

CL-USER> (macroexpand-dammit '(macrolet ((m (n) `(* ,n 2))) (defun f (&key (m (m 1))) (m m))))

(DEFUN F (&KEY (M (* 1 2))) (* M 2))


Any advice and especially an automated test suite I could piggyback on
would be absolutely great.

One issue that comes up with Lispworks is that compiler-let is heavily
used. Secondly, 

CL-USER> (special-operator-p 'compiler-let)
NIL
CL-USER> (macroexpand-1 '(compiler-let ((x y))))
(COMPILER-LET ((X Y)))
NIL
CL-USER> (macro-function 'compiler-let)
NIL

Shouldn't it at least be a special-operator?







Updated at: 2020-12-10 08:40 UTC