Does Clojure approach single-user space in any way when programming macros?

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?

+7
macros clojure common-lisp
source share
1 answer

I have never encountered limitations with the Clojure macro system. This is a completely general macro system, and as far as I know, it is completely comparable to Common Lisp in terms of fundamental capabilities.

Obviously, there are many syntactic differences, but I think they are mostly superficial and do not affect the expressive power you can achieve with macros.

My opinion is that Clojure gets a lot of design aspects right here:

  • Lisp -1 is simpler and more understandable than Lisp -2, especially in a functional language, where you really have to treat functions as first class values .
  • Character capture is usually not a problem - the syntax quote and the Clojure namespace system do a good job of creating macros for both use and reading.

As a final comment, a summary of the related article is sufficiently illuminated:

The main part of arguments devoted to pure semantics and notation of simplicity, as a rule, promotes the unification of function namespaces and values ​​..... We believe that the time for such a radical change in Common Lisp has passed, and that would be the task of future Lisp designers to learn from Common Lisp and Scheme to create an improved Lisp.

In my humble form, Clojure is a good example of "enhanced Lisp."

+1
source share

All Articles