Free Pascal has support for procedural types, although it differs from the Turbo Pascal implementation of them.
The type declaration remains the same. The two following examples are valid type declarations:
Type TOneArg = Procedure (Var X : integer); TNoArg = Function : Real; var proc : TOneArg; func : TNoArg;Given these declarations, the following assignments are valid:
Procedure printit (Var X : Integer); begin writeln (x); end; ... P:=@printit; Func:=@Pi;From this example, the difference with Turbo Pascal is clear: In Turbo Pascal it isn't necessary to use the address operator (@) when assigning a procedural type variable, whereas in Free Pascal it is required (unless you use the -So switch)
Remark that the modifiers concerning the calling conventions (cdecl, pascal, stdcall and popstack stick to the declaration; i.e. the following code would give an error:
Type TOneArgCcall = Procedure (Var X : integer);cdecl; var proc : TOneArgCcall; Procedure printit (Var X : Integer); begin writeln (x); end; begin P:=@printit; end.Because the TOneArgCcall type is a procedure that uses the cdecl calling convention.