Jump to content

Lisp reader

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Macrakis (talk | contribs) at 20:45, 12 February 2013 (syntax). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In the programming language Lisp, the reader or read function is the parser which converts the textual form of Lisp objects to the corresponding internal object structure.

In the original Lisp, S-expressions consisted only of symbols, integers, and the list constructors ( xi... ) and (x . y). Later Lisps, culminating in Common Lisp, added literals for floating-point, complex, and rational numbers and constructors for vectors.

Read table

The reader is controlled by the readtable, which defines the meaning of each character.

Read macros

Unlike most programming languages, Lisp supports parse-time execution of programs, called "read macros" or "reader macros". These are used to extend the syntax either in universal or program-specific ways. For example, the quoted form (quote x) operator can be abbreviated as 'x. The ' operator could be defined as a read macro which reads the following list and wraps it with quote.

Notes


Bibliography

Template:Programming-stub