What's Lisp-1, What's Lisp-2? Bad Jargon or Good Jargon?
What's lisp-1, what's lisp-2?
“lisp-2” is any lisp language that allow you to have the same name for both function and variable.
Emacs Lisp is “lisp-2”:
;; emacs lisp is lisp-2 (defun xx (yy) yy ) ; a function that returns its arg (setq xx 4) ; a variable with value 4 (print (xx 3)) ; prints 3 (print xx) ; prints 4 ;; note that both the function and the variable are named xx
;; a builtin variable holds buffer's file path buffer-file-name ;; a builtin function that returns buffer's file path (buffer-file-name)
Ruby is also “lisp-2”:
# -*- coding: utf-8 -*- # ruby is lisp-2. use same name for different things def xx() 1 end xx = 2 p xx # 2 p xx() # 1
Perl is kinda “lisp-2”:
# -*- coding: utf-8 -*- # perl # using the same name for different things $aa = 4; # scalar @aa = (1, 2, 3); # array %aa = ('e' => 4, 'f' => 5); # hash print $aa, "\n"; print @aa, "\n"; print %aa, "\n";
Why You Should Not Use the Jargons Lisp-1 Lisp-2
“lisp-2” should be called multi-value-namespace languages.
“lisp-1” should be called single-value-namespace languages.
Someone 〔Propon…@gmx.net〕 wrote:
Having read Touretzky's introduction and the first half of Paul Graham's On Lisp, I'm wondering what the advantages of a Lisp-2 are over a Lisp-1
It seems to me that a Lisp-2's ability to use a single symbol to represent both a function and a value is a minor advantage, although I'm sure some regard it as a disadvantage. On the other hand, a Lisp-2 requires the clunky, IMHO, #' operator and cannot have a elegant, universal DEFINE like Scheme's.
Yet I've heard that a Lisp-1's macros are necessarily less powerful than those of a Lisp-2. Is that true? Are there some other big advantages of a Lisp-2 that I'm missing?
Please try to avoid the jargons lisp-1 and lisp-2.
lisp-1 lisp-2 are Opaque Jargon
The jargon lisp-1 and lisp-2 is one of better example that illustrate the harm of jargons in functional languages.
• The jargon is opaque. The words do not convey their meanings.
• Being a opaque jargon, it is often used subconsciously by people in a group, to communicate that they are in-group. (a class-differentiation strategy of human animals; as is much of slang's purpose) And consequently, these jargons are thrown about often without the writers actually understanding, or wishing to discuss about it in any way.
Not a Important Language Issue
Further, this issue is relatively minor, having little real-world practical impact. It is not unlike a war about which end of egg one should crack. (i.e. big endian vs little endian; See: Gulliver's Travels. PART I — A VOYAGE TO LILLIPUT, Chapter 4)
Why is this issue minor? Consider it broadly in human animal's computing activities. I give 2 examples:
Consider that in the 1960 people went to moon. (Moon landing) Imagine what complexities involved in the physics, mathematics, computation, at a time when computer are some one thousand times slower than today, using punch-cards, and there are not much of computer languages, not even modular programing.
For another example, consider today's PHP language. Linguistically, it is one of the most badly designed language, with many inconsistencies, WITH NO NAMESPACE MECHANISM, yet, it is so widely used that it is in fact one of the top 5 most deployed languages. If one of PHP or lisps and all associated applications written in them is to suddenly disappear from the face of this earth as a catastrophic punishment from Zeus, and all the leaders of nations is to have experts to assess the damage as they do with natural disasters, it is probable that PHP would be a order of magnitude greater loss.
Now, suppose we narrow the scope of “lisp-1 vs lisp-2” to its context: computer language design. There are many issues in language design. For example: dynamic scope vs lexical variable scope, various models of typing systems (dynamic, static, variable/value based, algebraic types, no types, with or without inference system), computing paradigm (OOP, Functional, procedural, pattern matching, database), evaluation model (greedy vs lazy) … etc. Among all language design issues, the “lisp-1” vs “lisp-2” is really one of the least significant, which actually arise practically only in Lisp due to its peculiar concept of its “symbols”. 〔►see Emacs Lisp Symbol〕
The existence of a name to a concept or idea, especially a opaque jargon, tends to get people to throw the name and argue about it unnecessarily.
To people in the lisp communities, please stop using the term. If necessary, say Common Lisp's model or Scheme Lisp's model, or, use a explicit term like multi-namevalue-space and single-value-namespace.
How Did multi-value-space Came About
There's a curious question. Why is the “lisp-1 vs lisp-2” happens only in lisp, and we don't have “perl1 vs perl2”, “java1 vs java2”, “ML1 vs ML2”, or any language with a variation on this?
This has to do with the concept of lisp's symbol, which has “cells” to hold different values. 〔►see Elisp: Lisp Symbol〕 This doesn't exist in other languages (notably except Mathematica).
Now, a further question is then, why Common Lisp's symbol of a particular name can have multiple values? (That is, a name in CL can both be a variable and a function in the same block of code at the same time. (This peculiar fact, we might give it a professional terminology for ease of communication, and we might call it: Common Lisp's multi-value-space, or just multi-value-space.))
Now, the question is, why do Lisps before Common Lisp have this multi-value-space feature?
I do not know much about the technical aspects of Lisp's history. However, i can venture a educated guess.
Old Lisps's multi-value-space feature, just like so many of its features (the cons cell for lists, the function “sort” being destructive, and semi-regular syntax using nested parens, etc), is simply designed as is without necessarily explicit, important, rationales. In other words, it is probably a characteristic that happens to be convenient, easy to implement, or not thought about at the time, or simply went one way than the other. (as opposed to, prominent issues that calls for conscious, explicit, decisions with important ramifications, such as syntax (sexp), symbols system, evaluation model, …etc.)
Now, as i mentioned before, this (single/multi)-value-space issue, with respect to human animal's computing activities, or with respect to the set of computer design decisions, is one of the trivial, having almost no practical impact. And, because some human animals, in the history of their power struggle, is produced the byproduct of the jargons “lisp-1” and “lisp-2”. And due to the fact that which end of egg to crack is now blessed with a terminology that has all the countenance of impartiality, it furnishes and fuels countless arguments and fightings on this non-issue between the Scheme Lisp and Common Lisp factions, even when the origin of the power struggle on this particular issue (the Common Lisp Standard) has long died. (every few months the issue will rise up in comp.lang.lisp or comp.lang.scheme, with all colors and types of activities from sincere to trite to re-examination to political struggle to pacification.)
Note: for the technical details of the Common Lisp's value-space, and the origin of the jargons “lisp-1” and “lisp-2”, see:
〔 Technical Issues of Separation in Function Cells and Value Cells By Richard P Gabriel, Kent M Pitman. At http://www.nhplace.com/kent/Papers/Technical-Issues.html〕
The Meaning of Namespace
The terms “Lisp-1” and “Lisp-2” were invented to expressly AVOID mentioning Common Lisp or Scheme, therefore we shouldn't use the terms such as Common Lisp model or Scheme model to describe it.
The creation of these terms is in a context of a political struggle. Namely, in creating the Common Lisp standard, Kent Pitmant has tirelessly and repeatedly pointed out in the past decade here.
As i mentioned in the article, the political context for the birth of lisp-1 lisp-2 terminology is over, about 2 decades ago.
Except when discussing history, there's no need to stick with the jargon lisp-1 and lisp-2.
I think that if not for so much of the colorful jargon lisp-1/lisp-2, the issue wouldn't even be much noticeable as it is relatively unimportant. Common Lisp today is multi-value-space, and Scheme Lisp is single-value-space. That's just a language fact and there's not much one can do or want to do much about that in practice.
Kent says that people in the community naturally picked up these terms. Actually, in my opinion, the popularity and continued use of these terms has much to do with Kent's promotion. In the past decade in “comp.lang.lisp”, he constantly reminds people of his article, and even explicitly requests others to use the terms Lisp-1 and Lisp-2, as opposed to other terms people used when discussing this issue, such as “Common Lisp way” or “Scheme way”.
Lisp does not use the term “namespace” differently from other languages. The meaning is the same, only the implementation details are different.
Namespace is a context for names. For example, you might have a function named “CreateSound”, but this could be just defined in your file, or it could be imported from a library, and another library could also have a function called “CreateSound”. This is when the namespace concept becomes useful. For those curious, the “space” part of the terminology came from mathematics, for example, vector space, topological space. It effectively means a “set”. The reason that “space” and “set” are often synonymous is due to the study of geometry, because a space is a set of points.
The namespace concept is tightly connected with the language's library/package/module system. In Emacs Lisp, PHP, and Scheme Lisp, for examples, these languages actually do not have a namespace mechanism, so that you have to create unique names for every function or variable you write. (Note: PHP v5.3 (2008-10) and Scheme R6RS (2007-08) both introduced namespace mechanism but isn't in common use yet) In most other languages (For example, Perl, Python, Mathematica), there are namespace mechanisms, so that you could call a function in some library using full path, or that you could call that function without full path by “importing” the function's name into your current file's namespace.
Java solved the uniqueness problem by adopting the domain name system for library names, as a convention. So, if Joe writes a package, by convention he should name his package something like “com.joe-bloke.sound”. This domain name system has been adapted in few other language systems too (For example, XML namespace).
With regards to lisp, in emacs lisp for example, the lack of namespace is a major problem, and is also a major problem of Scheme Lisp. (Scheme Lisp's Spec version 6 http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-10.html#node_chap_7 tried to fix this problem but not without huge controversy of the design). And as far as i understand from hearsay of gossips here, it is also a major problem for Common Lisp.
The above is a brief introduction on the concept of namespace as it is used, and some of its issues.
Now, the jargon lisp-1 and lisp-2 refers to a concept entirely different from namespace. It has to do with what lisp calls a symbol's “function cell” or “value cell”. What these function cell and value cell basically means the value of lisp language's var/function/subroutine/class. (Note: var/function/subroutine/class are typically called a “name” in computer languages but in lisp is called “symbol”.) The “function cell” and “value cell” is effectively a “meaning space” (or “value space”). 〔►see Intro to Emacs Lisp Symbol〕
Thanks to Dario Bertini for Ruby example.