16
votes

Are there any differences between what in Common Lisp you'd call an atom, and a symbol?

Do these differences extend to other languages in the Lisp family?

(I'm aware that atom has a different meaning in Clojure, but I'm interested in the boundaries of what is a symbol.)

4
The name "atom" comes from the Greek "atomos" meaning "indivisible". So, molecules were thought to be composed of indivisible particles caled "atoms" and anything that's not a cons in Lisp cannot usually be split.erjiang

4 Answers

15
votes

In Common Lisp, atom is precisely defined as any object that is not a cons. See http://l1sp.org/cl/atom for more details.

I don't know about other languages in the Lisp family.

6
votes

'atom' is usually seen from list processing. In Common Lisp something is either a non-empty list or an atom. In former times an atom was also called 'atomic symbol', which is something slightly different. Now in Common Lisp atoms are not only symbols, but everything else which is not a cons cell (examples: strings, numbers, hashtables, streams, ...).

If something is not an atom (is a cons), the operations CAR, CDR, FIRST and REST can be used.

So atom is a group of data structure. A symbol is a certain data structure, which also happens to be an atom.

1
votes

In Scheme, an atom is anything that is not a pair:

> (pair? 1)
#f
> (pair? '(1 2 3))
#t
> (pair? 'a)
#f

Thus symbols are atoms, just as numbers and strings. atom has a similar definition in Common Lisp, where the function (atom object) is defined to be (not (consp object)).

0
votes

In Common Lisp, a symbol is very much like a variable in other languages, although more heavyweight (it isn't just a blank piece of memory big enough to hold a value). It is usually interned so it can be referenced by name, although it's possible to have anonymous symbols (much like memory in C that you might refer to only by pointer).

An atom is some value that isn't a cons cell. A symbol is an atom, and so is a number, a string, and lots of other things. The most common use of cons cells is in making up lists, although it's possible to use them in other ways.