In Lisp it is possible to connect the called properties with a symbol. Properties of a symbol enter the name in keeped together with a symbol a vector of properties.
The vector of properties can be empty or contain any quantity of properties. Properties are sorted by name . Its form is those:
#((name1 . value1) (name2 . value2) … (namen . valuen))
For example, at a symbol berry-ash can be such vector of properties:
#((color . red) (taste . sour))
The vector of properties of a symbol can be updated or deleted by means of additional methods. The programmer should provide and process its interesting properties itself.
With a symbol are connected only its name, any, appointed by function of giving (SETQ), value and appointed by definition of a class and methods (DEFCLASS, DEFMETHOD, …). Value and definition of a class are the built in system properties which operate work of the interpreter in various situations. The list of properties also is system property. Working with properties of symbols applied systems can freely define new properties.
Further we shall consider pseudo-functions for reading, changes and removals of the properties defined by the user.
To find out value of the property connected with a symbol, it is possible by means of function GET:
(symbol GET property)
If, for example, the vector of properties certain by us earlier we shall receive following results is connected with a symbol berry-ash:
>('berry-ash GET 'taste)
sour
>('berry-ash GET 'weight)
NIL
As the symbol berry-ash does not have property weight GET will return value NIL.
Giving of new property or change of value of existing property is carried out by function PUT:
(symbol PUT property value)
Properties of symbols are in the cells of memory connected with symbols. We shall give an example:
>('berry-ash PUT 'weight '(2 g))
(2 g)
>('berry-ash get 'weight)
(2 g)
By-effect of a call will be change of a vector of properties of a symbol berry-ash as follows:
#((color . red) (taste . sour) (weight 2 g))
Removal of property and its value is carried out by function REMPROP:
(symbol REMPROP property)
Let's give an example:
>('berry-ash REMPROP 'taste)
TRUE
>('berry-ash get 'taste)
NIL
Function REMPROP returns as value true or false. If deleted property is not present, comes back false. Property can be removed, having appropriated it value nil.
To read from a vector of properties, to create and update in it properties it is possible not only separately, but also entirely. For example, value of a call
(symbol PROPERTIES)
all vector of properties is:
>('berry-ash PROPERTIES)
#((color . red) (weight 2 g))
Properties of symbols irrespective of their values are accessible from all contexts until they will not be obviously changed or removed. Use of a symbol as function or a variable, i.e. change of value of a symbol or definition of function, does not influence other properties of a symbol, and they are kept.
Presence of properties is useful both for support of the system, and in many typical cases of data presentation. Use of properties gives means for considered after the programming operated by data by means of which it is possible to realize various languages of representation of knowledge and a formalism, such as semantic networks, frames and objects of object-oriented programming.