Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!mailrus!tut.cis.ohio-state.edu!bloom-beacon!mit-eddie!uw-beaver!cornell!rochester!PT.CS.CMU.EDU!SPICE.CS.CMU.EDU!skef From: skef@SPICE.CS.CMU.EDU (Skef Wholey) Newsgroups: comp.lang.lisp Subject: Re: Common Lisp Macro Expander Wanted Message-ID: <1348@PT.CS.CMU.EDU> Date: 7 Apr 88 22:11:05 GMT References: <49@spar.SPAR.SLB.COM> <23539@ucbvax.BERKELEY.EDU> Sender: netnews@PT.CS.CMU.EDU Organization: Carnegie-Mellon University, CS/RI Lines: 35 Jim Larus writes: From: larus@paris.Berkeley.EDU (James Larus) Subject: Re: Common Lisp Macro Expander Wanted How about: (defun macroexpand-all (f) (cond ((atom f) f) ((and (symbolp (car f)) (macro-function (car f))) (macroexpand-all (macroexpand f))) (t (mapcar #'macroexpand-all f)))) This is no good, because it doesn't know the syntax of special forms. For example, this call causes an error: (macroexpand-all '(let ((with-open-file t)) blag)) because it tries to descend blindly into the LET binding list as if it were a macro call, which it obvously ain't. It isn't too hard to write a code walker that Does The Right Thing for special forms in Common Lisp, but unfortunately some implementations ignore the rules stated in CLtL and make this more difficult than it ought to be. Older versions of Symbolics CL were pretty nasty in this respect, because they had macros expanding into implementation-dependent special forms and didn't supply macroexpansion functions for all the things specified as macros in CLtL. I believe this should have been fixed by now, but I can't easily check this. I have this suspicion that dozens of good CL code-walkers have been written independently, but none have made it into the public domain because they were written in profit-oriented institutions. Does anyone out there have one to donate? --Skef