There is something I always wondered ... Since in most cases Lisp prefers prefixed notations, why are conscells written in the form (A . B), which is an infixnotation as far as I see. Of course, when parsing a list, and creating its data structure, this notation does not really make the situation more complicated, since you could just read the next symbol, and then  if its not the dot  push a new cons cell on the cdr of the current one and set its car to the symbol, and if the list ends set the cdr to nil, if its a dot, push it, and set the cdr to the value given after the dot. And I see that this notation is handy when specifying lists which do not end in nil, like in scheme's definestatements for arbitrary many additional arguments.
I dont consider this a bad thing, I just always wondered why we have an infix notation here, while avoiding it on vitally every other place. Has it some historical reasons?
Why is conscellnotation infixed?

 Posts: 99
 Joined: Sat Jul 26, 2008 2:30 pm
 Location: Germany
 Contact:
Why is conscellnotation infixed?
Sorry for my bad english.
Visit my blog http://blog.uxul.de/
Visit my blog http://blog.uxul.de/
Re: Why is conscellnotation infixed?
The "infix" dot notation has certainly been there at the start.
You might want to check out McCarthy's 1960 article at
http://wwwformal.stanford.edu/jmc/recursive.html
Note the historical use of commas as separators in proper lists. The dot notation is probably a parallel to the commas, allowing symbolic atoms to use embedded spaces without escape mechanisms (such as slashification).
It might be noted that Lisp 1.5 supported both commas and spaces as separators, by making commas equivalent to a space.
You might want to check out McCarthy's 1960 article at
http://wwwformal.stanford.edu/jmc/recursive.html
Note the historical use of commas as separators in proper lists. The dot notation is probably a parallel to the commas, allowing symbolic atoms to use embedded spaces without escape mechanisms (such as slashification).
It might be noted that Lisp 1.5 supported both commas and spaces as separators, by making commas equivalent to a space.
Re: Why is conscellnotation infixed?
You have to be aware of the fact that the conscellnotation is a matter of
Sexpressions, not of Lisp code.
The parentheses and the dot are metacharacters that describe the structure of
data, and are on a lower level than the executable code they might represent.
Sexpressions by themselves are neither pre, in or postfix.
As (A . B) represents a single cell
it might indeed make sense to write it as (. A B)
But then (as you noted), what to do then with a structure like (A B C . D)
How would we denote that?
On the other hand, we could even say that the dot is a kind of prefix
notation, where the following expressions (here 'D') is to be stored in the CDR
part of the last cell.
Sexpressions, not of Lisp code.
The parentheses and the dot are metacharacters that describe the structure of
data, and are on a lower level than the executable code they might represent.
Sexpressions by themselves are neither pre, in or postfix.
As (A . B) represents a single cell
Code: Select all
+++
 A  B 
+++
But then (as you noted), what to do then with a structure like (A B C . D)
Code: Select all
+++ +++ +++
 A  +>  B  +>  C  D 
+++ +++ +++
On the other hand, we could even say that the dot is a kind of prefix
notation, where the following expressions (here 'D') is to be stored in the CDR
part of the last cell.