Demonstration of a Lisp1 versus a Lisp2

Scheme is what has been referred to as a Lisp1 language where all identifiers refer to values in the same namespace. As a result, + is always a function, no matter where it appears. Common Lisp is different, and is sometimes known as a Lisp2 language because identifiers refer to values in multiple namespaces. In CL, + is a function when appearing in a function position (e.g. when the reader has scanned it after a parenthesis for evaluation) but a value in other places. In CL you can use the FUNCTION function or the #' reader syntax to get the function value of an identifier. Additionally, it can sometimes be inferred by the interpreter / compiler, for example when providing lambdas to higher-order functions (this is part of the CL standard). Here are some examples in both Scheme and Common Lisp to demonstrate. The first is in CLISP:

[1]> <

*** - SYSTEM::READ-EVAL-PRINT: variable < has no value
The following restarts are available:
USE-VALUE      :R1      Input a value to be used instead of <.
STORE-VALUE    :R2      Input a new value for <.
ABORT          :R3      Abort main loop
Break 1 [2]> :R3
[3]> (function <)
[4]> #'<
[5]> (let ((< 1) (> 2)) (list (< < >) (> < >)))

As you can see, in CL when you attempt to use an identifier in a non-function context you will get an error about it not being defined; as a variable the identifier < above has no definition. But when using FUNCTION or the reader syntax we find its function definition. Because different namespaces are used for functions and data, we can make truly horrible-looking code and compare comparison identifiers. Now, the same in Chicken Scheme:

#;1> <
#<procedure C_lessp>
#;2> (let ((< 1) (> 2)) (list (< < >) (> < >)))
Error: call of non-procedure: 1

        Call history:

        <syntax>                (let ((< 1) (> 2)) (list (< < >) (> < >)))
        <syntax>                (begin (list (< < >) (> < >)))
        <syntax>                (list (< < >) (> < >))
        <syntax>                (< < >)
        <syntax>                (> < >)
        <eval>          (list (< < >) (> < >))
        <eval>          (< < >) <--

Here, when we ask for < we actually get the function straight away. And when we use LET we actually redefine the meaning of < such that we can no longer use it as a function. The reader tries to apply 1 as a function, but of course 1 is a number so it causes an error. The upshot of this is that in Common Lisp you are allowed to create identifiers which share the names of functions, like a variable called list, and nothing bad will happen. In Scheme, any such definition will shadow the function and prevent the function from being accessed.