In programming in language Lisp symbols and the symbol structures constructed of them are used. According to dictionary definition, the symbol (Greek "symbolon", the sign) is a recognition symbol, an artistic image, designating any thought, idea, etc. In Lisp the concept of the symbol is used in narrower and exact sense: record or the denotation is meant it.
The symbol is the name consisting of characters, digits and special signs which designates any subject, the object, a thing, operation from the real world. In Lisp symbols designate numbers, other symbols or more difficult structures, programs (function) and others Lisp objects. For example, "+" symbol can designate definition of operation of addition, "carbon-14" - a carbon isotope, etc.
Examples of symbols:
Language symbols can consist of characters, digits and some other signs, namely
+ - * / @ $ % ^ & _ \ < > ~.
Basically, interrogative and exclamative signs just as a tilde (~), and square brackets too can be a part of symbols, but are better to reserve these signs for special usage.
Symbols can consist both from capital, and of lower case letters though in the majority of Lisp-systems, as well as in a described dialect, capital and lower case letters are identified and represented by capital letters. Therefore, for example:
word ≡ Word ≡ WORD
Along with symbols in Lisp it is used also numbers which, as well as symbols, are written by means of signs limited by blanks. Numbers nevertheless are not characters as the number cannot represent others Lisp objects, except themselves, or the numerical value. Numbers differ from symbols in the way of record.
Symbols true, false and nil have in Lisp a special purpose: true designates logical value true, false - false, nil - nothing. By nil symbol it is designated as well the empty list. These symbols have always the same fixed built in value. They cannot be used as names of others Lisp objects.
Logical values true, false and nil are constants, other symbols - variables which are used for the denotation of others Lisp objects.
Symbols, numbers, strings and other embedded objects of language represent those elementary objects of which other structures are under construction. Therefore them name as atomic objects or it is simple atoms.
Atoms and lists are main data types of language. In a natural language as the list understand the list. The list in Lisp is the arranged sequence which units are atoms or lists. Lists consist in parentheses, list units are divided by blanks. The list always starts with an opening bracket and is ended by a closing bracket. For example, the following list consists of three characters and one sublist which in turn consists of two atoms:
(x y (z 1) 2)
The list is multilevel data structure in which opening and closing brackets are in strict correspondence. For example, brought below expression are correctly made lists:
(+ 2 3) - the list from three units
(((((first) 2) third) 4) 5) - the list from two units
In following lists accordingly 7 and 4 units:
(Good afternoon the bearded man has told)
(cat-37 (nickname Peter) (color ?) (tail nil))
The list in which there is no unit, is named as the empty list and is designated () or nil symbol. The empty list is not the same, that "nothing". It fulfils the same role, as zero in arithmetics. nil can be, for example, a unit of other lists:
nil ≡ ()
(nil) ≡ the list consisting of atom nil
(()) ≡ (nil)
((())) ≡ ((nil))
(nil ()) ≡ the list consisting of two empty lists
Lists can be used for representation of every possible knowledge. For example, for the characteristic of the hero of comics Zippy the Pinhead following expression would suit:
(meets Lisp-machines and comics))
Record in the form of the list is floppy, free under the form and is simultaneously enough exact and clear. Apparently from an example, such record with layout of the text opening structure helps to receive common view about structure and to penetrate into it. At input of expressions in Lisp-system null strings, blanks and text layout are ignored.
Planning of a way of data representation and knowledge and solution of a problem of their map are the major moments at programming in language Lisp. It is a question of finding of a way of record which would facilitate programming and was natural both to the task description, and for operation with data. Often it is possible to offer the record form, in any measure similar to the task and allowing to simplify further operation.
Programming in language Lisp, the task usually try to divide into more simple components. In data structure try to display as much as possible everything, that is known about the task, and, thus, to simplify programming. It allows to add new knowledge in system, not changing the program to apply the same program with different knowledge and to solve challenges by means of simple programs.
One of the main differences of language Lisp from traditional programming languages is record in the form of lists not only data, but also programs. For example, the list (2 + 3) can be interpreted depending on an environment and usage or as the operation giving as a result number 5, or as the list consisting of three units. The way of interpretation is defined by position of expression and algorithm of functioning of Lisp-system.