Quick start manual
Data types, variables, and constants
5-31
Procedural types
The previous variables are all procedure pointers—that is, pointers to the address of a 
procedure or function. If you want to reference a method of an instance object (see 
Chapter 7, “Classes and objects”), you need to add the words of object to the 
procedural type name. For example
type
TMethod = procedure of object;
TNotifyEvent = procedure(Sender: TObject) of object;
These types represent method pointers. A method pointer is really a pair of pointers; 
the first stores the address of a method, and the second stores a reference to the object 
the method belongs to. Given the declarations
type
TNotifyEvent = procedure(Sender: TObject) of object;
TMainForm = class(TForm)
procedure ButtonClick(Sender: TObject);
ƒ
end;
var
MainForm: TMainForm;
OnClick: TNotifyEvent
we could make the following assignment.
OnClick := MainForm.ButtonClick;
Two procedural types are compatible if they have
• the same calling convention,
• the same return value (or no return value), and
• the same number of parameters, with identically typed parameters in 
corresponding positions. (Parameter names do not matter.)
Procedure pointer types are always incompatible with method pointer types. The 
value nil can be assigned to any procedural type.
Nested procedures and functions (routines declared within other routines) cannot be 
used as procedural values, nor can predefined procedures and functions. If you want 
to use a predefined routine like Length as a procedural value, write a wrapper for it:
function FLength(S: string): Integer;
begin
Result := Length(S);
end;










