<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 9.00.8112.16430"></HEAD>
<BODY><!-- Converted from text/plain format -->
<P><BR><BR><FONT size=2>-----Original Message-----<BR>From:
users-bounces@racket-lang.org [</FONT><A
href="mailto:users-bounces@racket-lang.org"><FONT
size=2>mailto:users-bounces@racket-lang.org</FONT></A><FONT size=2>] On Behalf
Of Mark Engelberg<BR>Sent: viernes, 15 de julio de 2011 20:34<BR>To: Sam
Tobin-Hochstadt<BR>Cc: users list; Matthias Felleisen<BR>Subject: Re: [racket]
Again on bindings visibility in eval<BR><BR>OK, so here are the main points I'm
gathering from this discussion.<BR><BR>1. Clojure's quasiquote system does
some extra things behind the<BR>scenes in terms of generating temporary
variables and qualifying<BR>variable names with their namespace in such a way
that the macros you<BR>write are reasonably hygienic.<BR>2. They are not
perfectly hygienic because the gensym is simplistic<BR>and there may be ways to
defeat it if someone tried hard enough.<BR>Also, rebinding the global things
that the macro depends on may result<BR>in unintended behavior. (Then
again, you could argue that if you<BR>rebind the global "if", you really do want
macros like "while" to<BR>change.)</FONT></P>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2> </DIV>
<P><BR><BR><FONT color=#ff0000>That certainly is not what I would want. In
one of the first Lisp-like languages I met (IBM) I redefined a macro
such as to find out that many other macros where affected. Not my idea. We
have to take into account taat even a very experienced user may not know
which other forms are going to be affected. SCOPE is
important.<BR>Jos<BR><BR></FONT><BR><BR><BR><BR><BR>3. Clojure does not
have macros that are only valid within some local<BR>context. All macros
are global, and this might result in a lack of<BR>expressiveness versus Racket's
system.<BR>4. Racket's macro system tracks things like source code
location (and<BR>possibly other things?) useful for debugging.<BR><BR>Point 3 is
the main one I'm still getting my head around. I had to do<BR>a little
research to understand what everyone was talking about here<BR>with "local
macros" and "scoped macros". I see now that in Racket, if<BR>you define a
macro inside some sort of function body (or other lexical<BR>scope), it is only
valid within that scope.<BR><BR>Here are a couple of examples from Clojure to
contrast that behavior with:<BR>(def x 3)<BR><BR>(let [x 2]<BR> (defmacro
apply-to-x [y]<BR> `(~y ~x)))<BR><BR>In this code snippet, x
is a global, and apply-to-x is a global macro,<BR>but the macro does look up x
in its local context, i.e., (apply-to-x<BR>identity) yields 2, not 3.<BR><BR>On
the other hand removing the ~ from the x like this:<BR>(let [x 2]<BR>
(defmacro apply-to-x [y]<BR> `(~y x)))<BR>causes the x in the
macro to refer to the global x. So, (apply-to-x<BR>identity) yields
3.<BR><BR>So it is possible in Clojure to make the macro refer to its
local<BR>scope, but the macro itself is always global.<BR><BR>I recognize that
this means there are things you can do in Racket with<BR>macros that would be
extremely difficult or impossible in Clojure, but<BR>I don't have a good sense
for how often this would occur in practice.<BR>I gather it would be more of an
issue for things on a large scale like<BR>Racket's class
system.<BR>_________________________________________________<BR> For
list-related administrative tasks:<BR> </FONT><A
href="http://lists.racket-lang.org/listinfo/users"><FONT
size=2>http://lists.racket-lang.org/listinfo/users</FONT></A> </P></BODY></HTML>