Talk:S-expression

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
WikiProject Computing / CompSci (Rated Start-class, Low-importance)
WikiProject icon This article is within the scope of WikiProject Computing, a collaborative effort to improve the coverage of computers, computing, and information technology on Wikipedia. If you would like to participate, please visit the project page, where you can join the discussion and see a list of open tasks.
Start-Class article Start  This article has been rated as Start-Class on the project's quality scale.
 Low  This article has been rated as Low-importance on the project's importance scale.
Taskforce icon
This article is supported by WikiProject Computer science (marked as Mid-importance).
 

Are s-exprs data structures, or a notation for them?[edit]

The article presents an (somewhat implicit) definition of s-exprs as binary trees with atoms as the leaves, but McCarthy himself defined them as notation that translates to these structures:

We shall now define the S-expressions (S stands for symbolic). They are formed by using the special characters
.
)
(
and an infinite set of distinguishable atomic symbols.

I think the article should be changed to reflect this. The whole point of s-exprs is to convey lists, not to represent them in memory as cons cells or in any other way. Qwertyus (talk) 11:19, 16 February 2012 (UTC)

True, it is the first time I see sexps described as pairs, and it is all the more misleading with the illustration, which also shows a binary tree, but not the same as pairs. The article needs a serious rewrite. Nowhere man (talk) 13:54, 7 August 2013 (UTC)


The diagram is incorrect - it's missing terminating NILs. I've replaced it with a rough PNG that shows the actual cons cell structure as trees (though this is not the ideal visualisation for cons cells). But at least the NILs are visible now. Natecull (talk) 03:47, 17 February 2014 (UTC)

Python parsing code example[edit]

The parser function is beautiful, but it has some errors. If the input is "1" the result is []. "1 1" gives ['1'], but "1 1 ()" gives ['1', '1', []]. Also, it lacks error handling to deal with mismatched (missing or extraneous) parentheses. Although I realize that code examples can't be expected to be complete, I think it would be nice if this was fixed. Alas, I am not a Python programmer... --Lasse Hillerøe Petersen (talk) 22:14, 28 June 2017 (UTC)