Till now we considered functions which as arguments received the forms representing expressions, being data. Values of functions also were considered concerning as to data, i.e. the expressions treated as data.
Being based on uniform data presentation and programs, function as argument can specify and function, or, in other words, definition of function, or a symbol representing function. Argument which value is function, name in functional programming by functional argument, and the function having functional argument - functional.
Distinction between concepts "data" and "function" is defined not on the basis of their structure, and depending on their use. If the argument is used in function only as the object participating in calculations we deal with the ordinary argument which is submiting data. If it is used as the means defining calculations, i.e. plays calculations, for example, a role of lambda-expression which is applied to other arguments we deal with function.
The same expression can act in connection with various aspects, on the one hand, as ordinary argument, and on the other hand, as functional. The role and interpretation of expression depend on its syntactic position. We shall 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 functions first lambda-expression is not functional argument, and first does not become functional. The same lambda-expression costing in a position of function, is already interpreted as function while first is interpreted as data. Functional argument and functional are some generalization of simple concept of function: functional argument can be any suitable object which is used in a functionals body in a position of function and in a role of function.
Further we shall use concepts of function, a call of function and value of function of following sense:
Function is functional if as its argument it is used lisps object of type which is interpreted as function in a body of functional. Such functional object can be the symbolical name representing definition of function (system function or the function certain by the user) or anonymous lambda-expression.
The actual parameter for functional argument of functional is set in the form of the form which value will be object which can be interpreted as function. We shall result examples:
'(lambda () (nil list this))
(nil list 'lambda nil (nil list nil 'list 'this))
('(first rest cons) first)
Argument of function can be function, however, function can be and result. Such functions name functions with functional value. Functional also can be with functional value. The call such functional returns new function in which construction, probably, the functions received by functional as arguments are used as result. Such functionals we shall name functional with functional value.
For start of function which turns out result by functional, it is possible to use function eval or macros.
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, refer to 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 opportunities for programmers, allowing complex calculations to write down 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 functions with functional value.
Transfer of function as parameter 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 operated by data, and object-oriented programming. Functions of higher order are closely connected with objects and, and also with the partial and postponed calculations.
Functions of higher order are closely connected with abstract concepts and reflects. Theoretical and practical possession of them assumes skill to consider types of functions, i.e. to consider types of arguments accepted by them and values returned by them.