Re: Clojures macro system is essentially hygienic -- In the good sense.

2011-04-12 Thread CuppoJava
Paul Graham's "On Lisp" has a nice little section on anaphoric macros. It has a few nice tricks, but generally the Clojure style tends to avoid them if possible. ie. using if-let instead of an anaphoric-if macro. Also, I think the book Rob was referring to is called "Let Over Lambda" by Hoyte. As

Re: Clojures macro system is essentially hygienic -- In the good sense.

2011-04-12 Thread rob levy
Sometimes it is useful to have a referentially opaque symbol that you can refer to when calling a macro. Clojure's design encourages the idiom of let bindings instead of anaphora to maintain referential transparency, but in some cases it is preferable to capture a symbol and make use of it. If yo

Re: Clojures macro system is essentially hygienic -- In the good sense.

2011-04-12 Thread Jeffrey Schwab
On Tuesday, April 12, 2011 9:25:25 AM UTC-4, rob wrote: > > 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

Re: Clojures macro system is essentially hygienic -- In the good sense.

2011-04-12 Thread rob levy
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

Re: Clojures macro system is essentially hygienic -- In the good sense.

2011-04-11 Thread Armando Blancas
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 (ma

Re: Clojures macro system is essentially hygienic -- In the good sense.

2011-04-10 Thread Konrad Hinsen
On 11 Apr 2011, at 03:50, George Rogers wrote: ;;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 That's due to namespaces, which indeed solve many of the "hygiene" probl

Clojures macro system is essentially hygienic -- In the good sense.

2011-04-10 Thread George Rogers
(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.