> Most programming languages have several syntax rules. Lisp has one: everything is a list.
Oh, not again. The author is confusing s-expression syntax with Lisp syntax. Even s-expressions are more than lists (conses, cyclic conses, symbols, vectors, strings, various numbers, structures, ...) and the s-expression reader knows about more than pure s-expressions - for example comments. Not every s-expression is a valid Lisp expression. For example (let "let") is not a valid Common Lisp expression. The syntax for LET is:
let ({var | (var [init-form])}*) declaration* form* => result*
This is also using the syntax definition for 'declaration' and 'form'.
Lisp has built-in syntax (provided by special operators in Common Lisp) and arbitrary complex syntax provided by macros. This is valid for other languages with a notation based on s-expressions, like Scheme or Clojure.
It's one of the sentences which creates endless confusions and a false image of Lisp. 'Everything is a list'. Oh, Lisp has only one data structure? Lisp is difficult to read, because it has no other syntax? Lisp is a primitive language and not usable for real programmers... etc. etc. It also creates the impression that even proponents of Lisp-like languages don't actually understand the basics...
Who is endlessly confused? Who suspects that the author of a neat lisp editor plugin has never written a non-trivial line of Common Lisp, Clojure, or Scheme? What are the chances that people in either category are also curious and excited to experiment with novel editing techniques?
It's not. Explain Lisp to people not by treating them as idiots who won't understand that not everything is a list. There are numbers, vectors, strings, and various other forms of syntax in Lisp.
(john "123" 1) consists of a list, a symbol, a string, an integer
|hi there| is a symbol
#*1010101011 is a bit vector
#2A((1 1 1) (1 1 1)) is a 2d array
and so on.
Also look up the current Scheme report and see its syntax definition. 'Everything is a list' is fooling the reader and treating him/her like an idiot.
If you pick up just about any book on Lisp, it's all about recursion and lists. I don't remember SICP talking about native vectors or hash tables. I don't remember Touretzky talking about those either (maybe it was just that I had an early edition (1988-ish?) or my memory was faulty). Certainly The Little Lisper/Schemer never talks about them. The first book I remember talking about other primitives in Lisp was Siebel's "Practical Common Lisp". There are quite a few pernicious fallacies the swim around the "everything is a list", "S-exprs are easy to parse because they're uniform" (oh, really? Try identifying a list in the presence of dotted pairs), etc.
Hardly "pedantic" to point out imprecise language in a post about parsing source code. It's hilariously wrong when you consider the author's focus on Clojure, which introduces all sorts of wonky syntax.
Indeed the article begs for potshots from smug lisp weenies: 1) It's clearly talking about Clojure, yet leads with "Let's simplify the way we write Lisp". Them's fighting words in the Lisp corral. 2) Paredit clone, but only acknowledges that for animations. 3) No emacs version! (Understandable given #2 however)
I'm the first to call out grammar nazi's and pedantic crap. Despite that, lispm is right to call it out for a correction. It's a factually inaccurate statement that's gives non-LISP readers a misleading impression about what the language and its machine code are likely capable of. It's also spread like wildfire due to constant repetition as lispm noted.
So, it's worth mentioning and replacing with something more accurate.
>The author is confusing s-expression syntax with Lisp syntax.
Then again what he says is true for 99% of the cases, and a good simplification. >Even s-expressions are more than lists (conses, cyclic conses, symbols, vectors, strings, various numbers, structures, ...) Still expressed as lists when it comes to the syntax level.
> Then again what he says is true for 99% of the cases, and a good simplification.
It's not. Read it slowly: only a subset of s-expressions are valid Lisp programs. Examples for invalid Lisp programs, even though valid s-expressions:
(cl:if x > 1 t nil) ; IF takes 2 or three forms
((cl:lambda) (a) a) ; not a valid lambda expression
(cl:let "a let expression" ((a 1)) (+ a 1)) ; the second element should be a list of bindings
(cl:defun foo args (length args)) ; arguments needs to be a list
(cl:let ((a nil t)) a) ; a binding is a variable or a list of symbol/value
and so on.
Lisp syntax is not the syntax of s-expressions. Lisp syntax is defined ON TOP of s-expressions. > Still expressed as lists when it comes to the syntax level. Comments are not expressed as lists. Feature expressions are not lists. etc etc...
>only a subset of s-expressions are valid Lisp programs.
Sure, but the thing we're debating is whether "all s-expressions are valid Lisp programs" (that would be a miracle actually), but whether Lisp syntax is all lists. And all those examples are still lists -- that the lists can also contain other items inside them, or that underneath they are implemented as cons etc, doesn't really change that. >Comments are not expressed as lists. They are not retained anyway when the strings are parsed to the "live" AST (AFAIK), so they are an exception to the other syntax in that too.
Comments (134) 36 threads
Show all comments
Showing thread 6 of 36
Oh, not again.
This is also using the syntax definition for 'declaration' and 'form'.The author is confusing s-expression syntax with Lisp syntax. Even s-expressions are more than lists (conses, cyclic conses, symbols, vectors, strings, various numbers, structures, ...) and the s-expression reader knows about more than pure s-expressions - for example comments.
Not every s-expression is a valid Lisp expression. For example (let "let") is not a valid Common Lisp expression. The syntax for LET is:
Lisp has built-in syntax (provided by special operators in Common Lisp) and arbitrary complex syntax provided by macros.
This is valid for other languages with a notation based on s-expressions, like Scheme or Clojure.
That sentence is an oversimplification to give context to the rest of the content in that section. Should probably have an asterisk to clarify.
Continue this thread — 6 replies
Also look up the current Scheme report and see its syntax definition. 'Everything is a list' is fooling the reader and treating him/her like an idiot.
In Lisp the cons structure is actually the primitive. Lists are built on top.
If you pick up just about any book on Lisp, it's all about recursion and lists. I don't remember SICP talking about native vectors or hash tables. I don't remember Touretzky talking about those either (maybe it was just that I had an early edition (1988-ish?) or my memory was faulty). Certainly The Little Lisper/Schemer never talks about them.
The first book I remember talking about other primitives in Lisp was Siebel's "Practical Common Lisp".
There are quite a few pernicious fallacies the swim around the "everything is a list", "S-exprs are easy to parse because they're uniform" (oh, really? Try identifying a list in the presence of dotted pairs), etc.
Continue this thread — 3 replies
Indeed the article begs for potshots from smug lisp weenies:
1) It's clearly talking about Clojure, yet leads with "Let's simplify the way we write Lisp". Them's fighting words in the Lisp corral.
2) Paredit clone, but only acknowledges that for animations.
3) No emacs version! (Understandable given #2 however)
So, it's worth mentioning and replacing with something more accurate.
Then again what he says is true for 99% of the cases, and a good simplification.
>Even s-expressions are more than lists (conses, cyclic conses, symbols, vectors, strings, various numbers, structures, ...)
Still expressed as lists when it comes to the syntax level.
It's not. Read it slowly: only a subset of s-expressions are valid Lisp programs. Examples for invalid Lisp programs, even though valid s-expressions:
and so on.Lisp syntax is not the syntax of s-expressions. Lisp syntax is defined ON TOP of s-expressions.
> Still expressed as lists when it comes to the syntax level.
Comments are not expressed as lists. Feature expressions are not lists. etc etc...
Sure, but the thing we're debating is whether "all s-expressions are valid Lisp programs" (that would be a miracle actually), but whether Lisp syntax is all lists.
And all those examples are still lists -- that the lists can also contain other items inside them, or that underneath they are implemented as cons etc, doesn't really change that.
>Comments are not expressed as lists.
They are not retained anyway when the strings are parsed to the "live" AST (AFAIK), so they are an exception to the other syntax in that too.
Continue this thread — 3 replies
alists are not expressed as lists.