On 07/15/2011 02:07 PM, Thomas Chust wrote:

yes, Clojure's mitigation strategy for avoiding hygiene problems has two
components: The #-suffix syntax that acts as a clever shorthand for
gensym and the `-quote syntax that employs reader magic to prefix every
symbol read inside the syntax-quoted expression with a namespace.

Gensym allows you to reliably avoid the problem that macro introduced
identifiers might inadvertently shadow user defined identifiers.

Unfortunately Clojure's gensym is not a "real" gensym in the usual
Lisp sense, rather it is like Common Lisp's "gentemp":

user=> (eval `(def ~(gensym) 42))
#'user/G__12
user=> user/G__12
42

i.e. the symbol is interned.

"gentemp" is widely considered a bad idea, even by the CL authors:
http://clhs.lisp.se/Body/f_gentem.htm

In particular:
"Just because gentemp creates a symbol which did not previously exist does not mean that such a symbol might not be seen in the future (e.g., in a data file---perhaps even created by the same program in another session). As such, this symbol is not truly unique in the same sense as a gensym would be. In particular, programs which do automatic code generation should be careful not to attach global attributes to such generated symbols (e.g., special declarations) and then write them into a file because such global attributes might, in a different session, end up applying to other symbols that were automatically generated on another day for some other purpose.

See also:
http://www.ai.mit.edu/projects/iiip/doc/CommonLISP/HyperSpec/Issues/iss183-writeup.html

Too bad Clojure revived this spectre from the past.
And apparently there is no way to do a "real" (uninterned) gensym.

BTW, I was wrong to say that quasiquote is undocumented, they just renamed it 
syntax-quote.
http://clojure.org/reader

Stephan
_________________________________________________
 For list-related administrative tasks:
 http://lists.racket-lang.org/listinfo/users

Reply via email to