In the article Technical questions of separation in function cells and value cells, Kent Pitman and Richard Gabriel explain the decision to make Common Lisp a Lisp - 2:
There are two ways to look at the arguments for macros and namespaces. First, one namespace is fundamental, so macros are problematic. Secondly, macros are fundamental, and therefore a single namespace is problematic.
Accordingly, when programming macros, one namespace in macro programming is inherently problematic.
But Clojure's approach is slightly different: backquote has namespace resolution.
In Chapter 9 of the On Lisp book, Paul Graham talks about avoiding variable capture by breaking code in packages:
However, packages do not provide a very general solution to the problem of seizing. First, macros are an integral part of some programs, and it would be inconvenient to separate them in their own packaging. Secondly, this approach does not provide protection against being captured by other code in macros package.
As far as I can see, Clojure's solution for capturing a variable looks like a packaged option shown by Paul Graham.
One of the main drawbacks that Paul Graham points out is that it would be inconvenient to separate macros in different packages, but Clojure backquote does this automatically by adding a character namespace, right?
So, is this a complete solution for capturing a variable? Or are Kent Pitman's words still applicable? If there is any problem that Common Lisp shared namespaces can handle what Clojure cannot, can you write an example?
macros clojure common-lisp
EuAndreh
source share