Node:BP Procedural Types, Next:Files, Previous:Data Types in BP and GPC, Up:Borland Pascal
In addition to BP's procedural types, GNU Pascal has pointers to
procedures:
type FuncPtr = ^function (Real): Real;
The differences between procedure pointers and procedural types are only syntactical:
@myproc
, in the latter case just with myproc
(which
can lead to confusion in the case of functions - though GPC should
always recognize the situation and not try to call the function).
myprocptr^
,
in the latter case just with myprocvar
.
myprocptr
in the first case and @myprocvar
in the
latter.
@myprocptr
, in the
second case with
@@myprocvar
!
One can use both kinds in the same program, of course, though it is recommended to stick to one kind throughout to avoid maximum confusion.
GNU Pascal also supports Standard Pascal's procedural parameters (see Special Parameters).
Furthermore, GNU Pascal allows you to call even local procedures through procedural pointers, variables or parameters without reverting to any dirty tricks (like assembler, which is necessary in BP).
The differences between the various kinds of procedural types,
pointers and parameters are demonstrated in the demo program
procvardemo.pas
. An example for calling local routines
through procedural parameters can be found in the demo program
iteratordemo.pas
.