Name and value of the symbol

Value of a constant is the constant

  Just as the expression which is function call, without a prior apostrophe represents value of expression, instead of expression, and atoms can be used for the denotation of any values. The attention is already paid that before Lisp constants (numbers and symbols true, false and nil) it is not necessary to put an apostrophe. As constants they designate themselves. If to enter a constant the interpreter as result will produce this constant:

>true ; value of  true  is itself
>'true  ; the apostrophe is not necessary

The symbol can designate any expression

  Symbols can be used as variables. In this case they can designate some expressions. Symbols initially do not have any value, as for constants. If, for example, we will enter functions symbol we will receive error message:

Error: Symbol functions have no value

  The interpreter here cannot calculate value of the symbol as it for it is not present.

SET calculates a name and links it

  By means of function set the symbol can assign or link to it some value. If, for example, we want, that functions symbol designated base functions Lisp we will enter:

>('functions  set '(first rest  cons  atom  eq))
(first  rest  cons  atom  eq)

  Now between functions symbol and value (first rest cons atom eq) link which is real before the operation termination if, of course, to this name function set will not assign new value is derivated. After assignment the interpreter can already calculate value of symbol functions:

(first  rest  cons  atom  eq)

  Pay attention, that set calculates both arguments. If before the first argument there is no apostrophe by means of function set it is possible to assign value of a name which turns out by calculation. For example, call

>((functions  first)  set '(to  climb up  in  a head))
(to climb up  in  a head)

assigns a variable first expression (to climb up in a head), as call (first) returns to function as value first character which is used as actual argument of function call set:

>(functions first)  ; the first argument of the previous call
>first  ; assigned by function  set  value
(to climb up  in  a head)
(first  rest  cons  atom  eq)

SETQ links a name, not calculating it

  Along with function set to link the character to its value it is possible by means of function setq. This function differs from set that it calculates only the second argument. The q character reminds of automatic blocking of calculation of the first argument in a function name. For example:

>(nil setq  functions '(first rest  cons  atom  eq))

  At function usage setq need for the apostrophe sign before the first argument passes.
  To check up, whether the atom is linked, it is possible by means of a predicate boundp which is true when the atom has any value:

>('withoutvalue boundp)
>('functions  boundp)
>('true boundp) ; the constant is always linked

Pseudo-function by-effect

  Functions set and setq differ from other considered functions by that besides they matter, they possess also a by-effect. The effect of function consists in link derivation between the symbol and its value, and value of function is linked value. The symbol remains linked to a defined value until this value will not change.
  In Lisp all operations return some value. Value is available even for such operations which main destination consists in realisation of a by-effect, such, for example, as binding of the symbol or output of results to the press. The functions possessing a by-effect, in Lisp name as pseudo-functions. We will be nevertheless both for functions, and for pseudo-functions to use concept of function if only there is no special need to underline by-effect presence.
  Pseudo-function call, for example the control transfer operator (and it too call), from the point of view of usage of its value can stand on a place of argument of other function. (In the programming languages grounded on the operator approach, it is usually impossible.)

>(nil list  ('a set 3)  4)
(3  4)
>(nil list  (('b  set 3)  + 4)  b)  ; arguments are calculated in a parallel way
Error: Symbol b have no value

  In practical programming of pseudo-function are useful and often necessary, though in the theory, pure functional programming, they are not necessary.

Interpreter EVAL call calculates value of value

  Interpreter Lisp is named eval, and it is possible the same as also other functions to call it from the program. At usual programming to call the interpreter it is not necessary, as this call implicitly is present at dialogue of the programmer with Lisp-system.
  Superfluous call of the interpreter can to remove, for example, the effect of locking of calculation or allows to find value of expression, i.e. to carry out double calculation:

>'(2  + 3)
(2  + 3)
>(nil eval  '(2 + 3))

  Here the interpreter calculates value of the first expression '(2 + 3), receiving as a result (2 + 3). Further call eval allows to start again the interpreter, and value of expression (2 + 3), i.e. 5 will be result. Initial expression is handled in two stages. We will bring some more examples:

>(nil setq  x '(a b c))
>(nil eval  'x)
(a  b c)
>(nil eval  x)  ; value of x is (a b c)
Error: have no function link of b for 3
>(nil eval  ''(a  b c))
(a  b c)
>'(nil  eval  x)
(nil  eval  x)

   ' and eval operate in mutual opposite directions and cancel effect each other.
   eval is universal function Lisp which can calculate any correctly made expression. eval defines semantics of forms, i.e. defines, what symbols and forms together with what and that are meant also by what expressions matter.
  It is possible compactly enough and to define semantics Lisp neatly on most Lisp. The most part of system programs in Lisp-systems is written on Lisp, and the user can easily change system depending on the requirements.

Basis cycle: READ-EVAL-PRINT

  With interpreter Lisp at the uppermost, command level, it is possible to describe dialogue by a simple cycle:

(cout write '>) ; prompt output
(nil  setq  e (cin  read))  ; expression input
(nil  setq  v (nil  eval  e)) ; calculation of its value
(cout print v)  ; result output
(cout write '>) ; cycle repetition

  Interpreter Lisp answers the question asked to it and new value waits.