Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between an atom and a symbol in Common Lisp?

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.)

like image 365
hawkeye Avatar asked Oct 04 '10 12:10

hawkeye


People also ask

What is an atom in Lisp?

In Lisp, all of the quoted text including the punctuation mark and the blank spaces is a single atom. This kind of atom is called a string (for “string of characters”) and is the sort of thing that is used for messages that a computer can print for a human to read.

Is a number an atom in Lisp?

Basic Building Blocks in LISPAn atom is a number or string of contiguous characters. It includes numbers and special characters.

What is a symbol Lisp?

Advertisements. In LISP, a symbol is a name that represents data objects and interestingly it is also a data object. What makes symbols special is that they have a component called the property list, or plist.


2 Answers

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.

like image 162
Xach Avatar answered Oct 16 '22 04:10

Xach


'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.

like image 23
Rainer Joswig Avatar answered Oct 16 '22 03:10

Rainer Joswig