Language:
Русский
English
Procedural types
Standard Pascal treats procedures and functions strictly as program parts that can be executed through procedure or function calls.
Borland Pascal has a much broader treatment of procedures and functions. Through procedural types, it allows procedures and functions to be treated as objects that can be assigned to variables and passed as parameters.
A procedural-type declaration specifies parameters and, for a function, result type.
The syntax for a procedural-type declaration is identical to procedure or function header, except that it omits the identifier after the procedure or function keyword.
Examples
type
Proc = procedure;
SwapProc = procedure(var X, Y: Integer);
StrProc = procedure(S: string);
MathFunc = function(X: Real): Real;
DeviceFunc = function(var F: text): Integer;
MaxFunc = function(A, B: Real; F: MathFunc): Real;
Parameter names in a procedural-type declaration to not affect the meaning of the declaration.
Borland Pascal does not let you declare functions that return procedural-type values.
A function result value must be a string, Real, Integer, Char, Boolean, Pointer, or a user-defined enumeration.