Till now we considered functions which as arguments received the forms representing expressions, being data. Values of functions also were considered concerning on type to data, i.e. the expressions treated as data.
Being grounded on uniform data representation and programs, function as argument can specify and function, or, in other words, function definition, or the character representing function. The argument which value is function, name in functional programming by functional argument, and the function having functional argument - a functional.
Distinction between concepts "data" and "function" is defined not on the basis of their structure, and depending on their usage. If the argument is used in function only as the object participating in calculations we deal with the ordinary argument which is submitting data. If it is used as a resource defining calculations, i.e. plays calculations, for example, a role lambda-expression which is applied to other arguments we deal with function.
The same expression can appear in connection with various aspects, on the one hand, as ordinary argument, and on the other hand, as functional. The role and expression interpretation depend on its syntactic position. We will give an example:
>('(lambda () (nil list this)) first) ; first - function
lambda ; lambda-expression - data
>('first (lambda () (nil list this))) ; first - data
(first) ; lambda-expression - function
Transferred to function first the lambda-expression is not functional argument, and first does not become a functional. The same the lambda-expression standing in a position of function, is already interpreted as function while first is interpreted as data. The functional argument and a functional are some generalisation of simple concept of function: any suitable object which is used in a functional body in a position of function and in a function role can be functional argument.
Further we will use concepts of function, function call and value of function of following sense:
Function is a functional if as its argument it is used the lisp object of type which is interpreted as function in a functional body. The character name representing definition of function (system function or the function defined by the user) or untitled lambda-expression can be such functional object.
The actual parametre for functional argument of a functional is set in the form of the form the object which can be interpreted as function will be which value. We will bring examples:
'(lambda () (nil list this))
(nil list 'lambda nil (nil list nil 'list 'this))
('(first rest cons) first)
Function can be argument of function, however, function can be and result. Such functions name as functions with functional value. The functional also can be with functional value. Call of such functional returns new function in which construction, probably, the functions received by a functional as arguments are used as result. We will name such functionals as functionals with functional value.
For start of function which turns out result of a functional, it is possible to use function eval or macroes.
The presented functionals and functions with functional value unlike the ordinary functions receiving as arguments and returning as value data or expressions which value are data, are named as functions of higher order. Ordinary functions irrespective of, recursive they or not, are functions of the first order.
Functions of higher order open new possibilities for programmers, allowing difficult calculations to write more shortly. Many things which in traditional languages or at the traditional approach difficultly or cannot be programmed, it is possible to define more clearly and more shortly, using various types of functionals and function with functional value.
Transmission of function as parametre of other function and creation of function by means of special forms makes a basis for new technologies of programming, such, for example, as the programming controlled data, and object oriented programming. Functions of higher order are closely linked to objects and macroes, and also with the partial and postponed calculations.
Functions of higher order are closely linked to abstract concepts and mappings. Theoretical and practical possession of them assumes ability to consider types of functions, i.e. to consider types of arguments accepted by them and values returned by them.