In Lisp it is possible to connect the called properties with a symbol. Properties of a symbol register in a vector of properties. At each symbol different properties.
The vector of properties can be empty or contain any quantity of properties. Properties are sorted by a name. Its form is that:
#((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 his name, any, appointed giving function (setq), value and appointed definition of a class and methods (defclass, defmethod, …). Value and class definition are the built in system properties which operate interpreter work in various situations. All list of properties also is system property. Working with properties of symbols applied systems can freely define new properties.
Further we will examine 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 defined by us earlier we will receive following results is connected with a symbol berry-ash:
>('berry-ash get 'taste) sour >('berry-ash get 'weight) nil
As at a symbol berry-ash is not present 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 will give an example:
>('berry-ash put 'weight '(2 g)) (2 g) >('berry-ash get 'weight) (2 g)
Change of a vector of properties of a symbol berry-ash as follows will be a call by-effect:
#((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 given 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
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 function definition, does not influence other properties of a symbol, and they remain.
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 examined after the programming operated data with which help it is possible to realise various languages of representation of knowledge and a formalism, such as semantic networks, frames and objects of object-oriented programming.