Subject: Re: Tutorial on writing Macros?
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 28 Oct 2000 02:54:13 GMT
Newsgroups: comp.lang.scheme
Message-ID: <8tdf4l$3kdg6$1@fido.engr.sgi.com>
Friedrich Dominicus  <frido@q-software-solutions.com.NO-spam> wrote:
+---------------
| rpw3@rigden.engr.sgi.com (Rob Warnock) writes:
| > 	> (pretty-print
| > 	    (expand-defmacro
| > 	      '(let ((in '(a b c d))
| > 		     (out '()))
| > 	         (dolist (i in out)
| > 	           (push i out)))))
| > 	(#%let-values
| > 	  (((in) (#%quote (a b c d))) ((out) (#%quote ())))
| > 	  (for-each (#%lambda (i) (#%set! out (cons i out)) out) in)
| > 	  out)
| 
| Oh yes, and that is what I would expect too. Just the last gives here:
| 
| (pretty-print (expand-defmacro
|                   '(let ((in '(a b c d))
| 		     (out '()))
| 	         (dolist (i in out)
| 	           (push i out)))))
| (#%let-values
|   (((in) (#%quote (a b c d))) ((out) (#%quote ())))
|   (dolist (i in out) (push i out)))
|    ^^^^^^             ^^^^^
| great expanson ;(
+---------------

Hmmm...  Which version of DrScheme/MzScheme are you using?  Perhaps
there's been some change in the definition of "expand-defmacro"?
My examples were done with MzScheme v.101. Like the current
version (103), it has two separate expansion functions:

	<URL:http://www.cs.rice.edu/CS/PLT/packages/doc/mzscheme/node147.htm>
	...
	(expand-defmacro s-expr) expands all macros in the S-expression
	s-expr and returns the new, expanded S-expression. 

	(expand-defmacro-once s-expr) partially expands macros in the
	S-expression s-expr and returns the partially-expanded S-expression. 

But your example looks more like "expand-defmacro-once".


-Rob

p.s. Hmmm... I think I need to upgrade. On v.101 even
"expand-defmacro-once" does the full expansion.  ;-}  ;-}

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
Network Engineering		http://reality.sgi.com/rpw3/
Silicon Graphics, Inc.		Phone: 650-933-1673
1600 Amphitheatre Pkwy.		PP-ASEL-IA
Mountain View, CA  94043