Subject: [clisp-list] macrolet walker?

From: Raymond Toy <[email-masked]>
Date: Wed Dec 11 07:49:07 2002

In Clisp 2.29, I notice that extended loop macroexpands into code that
uses macrolet.  When used with series (series.sourceforge.net), series
fails to process the code because it doesn't know how to walk the
macrolet code.

Is there a code walker in clisp that can be used to walk through
macrolets?  Series has support for a macrolet walker in LW and CMUCL.
Support for Clisp would be nice.

Ray

---

From: Sam Steingold <[email-masked]>
Date: Wed Dec 11 08:33:03 2002

> * In message <[email-masked]>
> * On the subject of "[clisp-list] macrolet walker?"
> * Sent on 11 Dec 2002 10:48:46 -0500
> * Honorable Raymond Toy <[email-masked]> writes:
>

CLISP has a code walker, of course, in src/init.lisp

what exactly do you need?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
To a Lisp hacker, XML is S-expressions with extra cruft.

---

From: Raymond Toy <[email-masked]>
Date: Wed Dec 11 10:44:07 2002

>>>>> "Sam" == Sam Steingold <[email-masked]> writes:

    Sam> CLISP has a code walker, of course, in src/init.lisp

    Sam> what exactly do you need?

I don't understand this very well, but this is what the comments say:

;; CL-USER 1> (defmacro foo (x) 
;;              `(bar ,x))
;; FOO
;;
;; CL-USER 2> (walker:walk-form '(macrolet ((bar (x) `(print ,x))) 
;;                                  (foo 3)))
;; (MACROLET ((BAR (X) (LIST (QUOTE PRINT) X))) 
;;   (PRINT 3))
;;
;; CL-USER 3> (walker:walk-form '(macrolet ((bar (x) `(print ,x)))
;;                                 (macrolet ((baz (x) `(bar ,x))) 
;;                                   (baz 3))))
;; (MACROLET ((BAR (X) (LIST (QUOTE PRINT) X)))
;;   (MACROLET ((BAZ (X) (LIST (QUOTE BAR) X))) 
;;     (PRINT 3)))

So basically, it needs to walk the macrolet forms and replace the code
with the macrolet expansions.  CMUCL uses the code-walker from PCL to
do this.

Thanks,

Ray

---

From: Sam Steingold <[email-masked]>
Date: Wed Dec 11 12:24:09 2002

> * In message <[email-masked]>
> * On the subject of "Re: [clisp-list] macrolet walker?"
> * Sent on 11 Dec 2002 13:43:33 -0500

(let ((SYSTEM::*FENV* nil) (SYSTEM::*vENV* nil))
  (sys::%expand-form '(macrolet ((bar (x) `(print ,x)))
                        (macrolet ((baz (x) `(bar ,x)))
                          (baz 3)))))
==>
(PRINT 3) ;
T

the second value means that something has been changed.

is this what you want?

would it be useful to export this as, say EXT:EXPAND-FORM
(or EXT:WALK-FORM, or ...)?

-- 
Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux
<http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/>
<http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html>
He who laughs last thinks slowest.

---

From: Raymond Toy <[email-masked]>
Date: Wed Dec 11 12:53:10 2002

>>>>> "Sam" == Sam Steingold <[email-masked]> writes:

    Sam> (let ((SYSTEM::*FENV* nil) (SYSTEM::*vENV* nil))
    Sam>   (sys::%expand-form '(macrolet ((bar (x) `(print ,x)))
    Sam>                         (macrolet ((baz (x) `(bar ,x)))
    Sam>                           (baz 3)))))
    Sam> ==>
    Sam> (PRINT 3) ;
    Sam> T

    Sam> the second value means that something has been changed.

    Sam> is this what you want?

I think this will do nicely.  I'll have to test it out though to be
sure.

    Sam> would it be useful to export this as, say EXT:EXPAND-FORM
    Sam> (or EXT:WALK-FORM, or ...)?

ext:walk-form sounds nice.  I notice that LW doesn't export their
walker::walk-form.  Neither does PCL.

Thanks!

Ray

---

From: Raymond Toy <[email-masked]>
Date: Thu Dec 12 06:51:02 2002

I tried this out.  It works nicely, and a little better than the LW or
PCL walker because they leave the macrolet forms in, which I then have
to skip over.

Thanks!

Ray