Separate Namespaces for Functions and Variables in Common Lisp versus Scheme

Scheme uses a single namespace for all variables, regardless of whether they are bound to functions or other types of values. Common Lisp separates the two, such that the identifier "hello" may refer to a function in one context, and a string in another.

(Note 1: This question needs an example of the above; feel free to edit it and add one, or e-mail the original author with it and I will do so.)

However, in some contexts, such as passing functions as parameters to other functions, the programmer must explicitly distinguish that he's specifying a function variable, rather than a non-function variable, by using #', as in:

(sort (list '(9 A) '(3 B) '(4 C)) #'< :key #'first)

I have always considered this to be a bit of a wart, but I've recently run across an argument that this is actually a feature:

...the important distinction actually lies in the syntax of forms, not in the type of objects. Without knowing anything about the runtime values involved, it is quite clear that the first element of a function form must be a function. CL takes this fact and makes it a part of the language, along with macro and special forms which also can (and must) be determined statically. So my question is: why would you want the names of functions and the names of variables to be in the same namespace, when the primary use of function names is to appear where a variable name would rarely want to appear?
Consider the case of class names: why should a class named FOO prevent the use of variables named FOO? The only time I would be referring the class by the name FOO is in contexts which expect a class name. If, on the rare occasion I need to get the class object which is bound to the class name FOO, there is FIND-CLASS.

This argument does make some sense to me from experience; there is a similar case in Haskell with field names, which are also functions used to access the fields. This is a bit awkward:

data Point = Point { x, y :: Double {- lots of other fields as well --} }
isOrigin p = (x p == 0) && (y p == 0)

This is solved by a bit of extra syntax, made especially nice by the NamedFieldPuns extension:

isOrigin2 Point{x,y} = (x == 0) && (y == 0)

So, to the question, beyond consistency, what are the advantages and disadvantages, both for Common Lisp vs. Scheme and in general, of a single namespace for all values versus separate ones for functions and non-function values?


  • The two different approaches have names: Lisp-1 and Lisp-2. A Lisp-1 has a single namespace for both variables and functions (as in Scheme) while a Lisp-2 has separate namespaces for variables and functions (as in Common Lisp). I mention this because you may not be aware of the terminology since you didn't refer to it in your question.

    Wikipedia refers to this debate:

    Whether a separate namespace for functions is an advantage is a source of contention in the Lisp community. It is usually referred to as the Lisp-1 vs. Lisp-2 debate. Lisp-1 refers to Scheme's model and Lisp-2 refers to Common Lisp's model. These names were coined in a 1988 paper by Richard P. Gabriel and Kent Pitman, which extensively compares the two approaches.

    Gabriel and Pitman's paper titled Technical Issues of Separation in Function Cells and Value Cells addresses this very issue.