Node: BP Procedural Types, Next: Files, Previous: Data Types in BP and GPC, Up: Borland Pascal

### BP Procedural Types

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:

- In the first case, one can pass/assign a procedure/function with `@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).
- In the first case, one can call the routine via `myprocptr^`, in the latter case just with `myprocvar`.
- To retrieve the address of a procedure stored in a variable, one can use `myprocptr` in the first case and `@myprocvar` in the latter.
- If, for some reason, one needs the address of the variable itself, in the first case, that's obtained with `@myprocptr`, in the second case with `@@myprocvar`!
- Bottom line: BP style procedural types are simpler to use in normal cases, but somewhat strange in the last example.

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`.