Free Pascal has support for procedural types, although it differs a little from the Turbo Pascal or Delphi implementation of them. The type declaration remains the same, as can be seen in the following syntax diagram:
_________________________________________________________________________________________________________
Procedural types
___________________________________________________________________
For a description of formal parameter lists, see chapter 11, page 478. The two following examples are valid type declarations:
One can assign the following values to a procedural type variable:
Given these declarations, the following assignments are valid:
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. In case the -MDelphi or -MTP switches are used, the address operator can be dropped.
Remark: The modifiers concerning the calling conventions must be the same as the declaration; i.e. the following code would give an error:
Because the TOneArgCcall type is a procedure that uses the cdecl calling convention.