Subject: Re: What's up with Scheme macros?
From: rpw3@rpw3.org (Rob Warnock)
Date: Sat, 16 Feb 2008 22:17:52 -0600
Newsgroups: comp.lang.lisp,comp.lang.scheme
Message-ID: <G4Wdnb26sovtKCranZ2dnUVZ_rmjnZ2d@speakeasy.net>
Pascal Costanza  <pc@p-cos.net> wrote:
+---------------
| (let ((x 42))
|    (macrolet ((foo () 'x))
|      (let ((x 4711))
|        (foo))))
| 
| Now assume you're not allowed to change the names of the x variable 
| bindings. In a defmacro-style macro system, there is no way that you can 
| ensure that the code to which foo expands refers to the outer x by just 
| changing the macro definition. Whatever you may try, the outer x will be 
| shadowed by the inner x in the inner expansion of foo.
+---------------

Not to disagree with your point about macro scope & shadowing,
but this paticular example is not at all compelling, since you
could easily have gotten the desired result with no macros at all!

    > (let ((x 42))
	(flet ((foo () x))
	  (let ((x 4711))
	    (foo))))

    42
    > (let ((x 42))
	(flet ((foo () x))
	  (let ((x 4711))
	    (flet ((bar () x))
	      (let ((x 937))
		(list (foo) (bar) x))))))

    (42 4711 937)
    > 

Look, Ma, no macros!

Sometimes I think that with all the bickering about macro style
we sometimes forget that Scheme & CL both share the amazing power
of lexical closures.

+---------------
| Hygienic macro systems solve this issue.
+---------------

But so do closures... and with less "new syntax".


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607