Clojure's automatic gensym feature in defmacro is similar to the idea
suggested in Hoyte's Common Lisp book "Let Them Eat Lambda", though I gather
it's not historically originated by Hoyte as similar ideas have been
implemented by others.  One Scheme advocate I know has that suggested that
it would be more hygienic to have gensyms be the rule instead of the
exception to the rule (you could still get capture by asking to *not*
gensym).  I'm not certain I agree with him, because I haven't fully
considered if that would add or reduce complexity when trying to do things
like anaphora (which is already made somewhat non-idiomatic).

On Mon, Apr 11, 2011 at 10:42 AM, Armando Blancas <armando_blan...@yahoo.com
> wrote:

> That's because of the order of the definitions of foobar and let.
> Thus:
>
> guik.evil=> (macroexpand '(foobar 10))
> (let* [a__44__auto__ 10] (clojure.core/+ a__44__auto__ a__44__auto__))
>
> But defining let before foobar:
>
> guik.evil=> (macroexpand-1 '(let))
> (guik.evil/let*)
> guik.evil=> (macroexpand-1 (macroexpand-1 '(let)))
> 2
> guik.evil=> (macroexpand-1 '(foobar 10))
> (guik.evil/let [a__17__auto__ 10] (clojure.core/+ a__17__auto__
> a__17__auto__))
> guik.evil=> (macroexpand-1 (macroexpand-1 '(foobar 10)))
> java.lang.IllegalArgumentException: Wrong number of args (4) passed
> to: evil$let (NO_SOURCE_FILE:0)
>
> which is fine since let now takes no args. But this will activate the
> local let*:
>
> guik.evil=> (defmacro let [& args] `(guik.evil/let*))
> #'guik.evil/let
> guik.evil=> (foobar 10)
> 2
>
> On Apr 10, 6:50 pm, George Rogers <atbusb...@gmail.com> wrote:
> > (ns guik.evil)
> > ;;1) Special forms cannot be shadowed
> > (defmacro let* []
> >   (+ 1 1))
> > ;; (let*) ; would yield
> > ;=> clojure.lang.Compiler$CompilerException:
> > java.lang.IllegalArgumentException: Bad binding form, expected vector
> > (evil.clj:6)
> > ;;2) Shadowing a macro does not change macros that depend on it.
> > (defmacro foobar [x]
> >   `(let [a# ~x]
> >      (+ a# a#)))
> > (defmacro let []
> >   `(guik.evil/let*))
> > (foobar 10) ;=> 20
>
> --
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with
> your first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to