What is the difference between Lisp-1 and Lisp-2?

22,269

Solution 1

According to wikipedia:

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.

It's basically about whether variables and functions can have the same name without clashing. Clojure is a Lisp-1 meaning that it does not allow the same name to be used for a function and a variable simultaneously.

Solution 2

You might like to read this paper by Richard Gabriel. It is a summary of the issues that the Lisp community were discussing in Lisp1 vs Lisp2. It's a bit dense and slow moving in the first few sections, but is much easier to read by the time you get past section 5.

Basically, Lisp1 has a single environment that maps symbols to values, and those values can be either "regular" or functions. Lisp2 has (at least) two namespaces (symbols have a slot for their a function value and one for a regular value). So, in Lisp2, you can have a function named foo and a value named foo, whereas in Lisp1, the name foo can refer only to a single value (function or otherwise).

There are several tradeoffs and differences of taste between the two, but read the paper for the details. Christian Queinnec's book, "Lisp in Small Pieces" also has discussion of the differences woven through the text.

Share:
22,269

Related videos on Youtube

yazz.com
Author by

yazz.com

CEO, Solidity and Web3 developer at https://yazz.com

Updated on July 08, 2022

Comments

  • yazz.com
    yazz.com almost 2 years

    I have tried to understand the difference between Lisp-1 and Lisp-2 and how this relates to Clojure but I still do not understand properly. Can anyone enlighten me?

  • yazz.com
    yazz.com over 13 years
    Isn't a Lisp-2 more confusing having functions and variables with the same names then?
  • Peter McLain
    Peter McLain over 13 years
    One of the more enigmatic sections of the Gabriel paper, is section 11 on Multiprocessing. In that section, he implies that Lisp1 is more conducive to a functional style of programming, hence more conducive to multiprocessing. Obviously, this is of interest wrt Clojure. But I'm not really sure why Lisp1 is more conducive to FP. Anyone have insight into this?
  • mikera
    mikera over 13 years
    probably because the major point of FP is to treat functions as first class values, hence it's much more convenient and conceptually cleaner to treat them in the same way as all other values
  • Kaz
    Kaz about 10 years
    @PeterMcLain When users of Lisp-1 dialects say tht Lisp-1 is more conductive to functional programming, what they mean is that you don't have to stuff the code full of funcall and function operators. These disappear in a Lisp-1.
  • Kaz
    Kaz about 10 years
    Part of the reason why is that programmers using Lisp-2 dialects do not go out of their way to have functions and variables having the same names. list is often used as a function parameter and nobody things, OMG that is so confusing since (list ...) is a standard function. Many functions that have list as a variable don't use the list function, or don't use it near that variable. Even when that does happen it's not too bad: (list foo list). This isn't any more confusing than a sentence like "fight the good fight" where the same word appears as a noun and verb.
  • ceving
    ceving over 7 years
    An example what happens when a Schemer tries to write Lisp: emacs.stackexchange.com/q/28979/2787
  • ceving
    ceving about 7 years
    @Zubair Java has even more name spaces. You can define a class, a method and a variable with the same name.
  • Daniel Dinnyes
    Daniel Dinnyes about 7 years
    you used the phrase "at least" about Lisp-2. The simple differentiation between the 2 cases is: whether the symbol is at the head position of an s-expression, or not (if so, then lookup in the function namespace, else in the variable namespace). Can you give some examples of other, than those 2 cases?
  • Will Ness
    Will Ness over 6 years
    @DanielDinnyes same name may refer to a value or to a function or (and that is the "at least" part) to other stuff, like restart designators, goto labels, etc. if I'm not mistaken. But to what you've said, there's also quoted arguments to mapcar and the like, some arcane rules of resolution there. Again IIANM.
  • Nick McCurdy
    Nick McCurdy over 6 years
    As a mnemonic, I think of Lisp 1s as having 1 namespace, and Lisp 2s having 2 namespaces (one for functions and one for variables).
  • BaseZen
    BaseZen over 5 years
    I just like that the paper uses the term "perspicuously" with the wonderfully ironic meaning "easier to understand".
  • Kaz
    Kaz over 4 years
    @NickMcCurdy As a mnemonic, I think of a bicycle as having two wheels, and tricycle having three.
  • Kaz
    Kaz over 4 years
    @BaseZen Where is the irony? In that "perspicuously" is a rarely used word of many syllables denoting clarity?
  • mseddon
    mseddon about 4 years
    @PeterMcLain I cannot recommend Quinnec's Lisp In Small Pieces enough. It's definitely required reading for anyone who wants a deep understanding of Lisp (the family of languages). It's also really important to follow through the references, too.