10.3.4 Constant parameters

In addition to variable parameters and value parameters Free Pascal also supports Constant parameters. A constant parameter as can be specied as follows:

_________________________________________________________________________________________________________ Constant parameters
-- constant parameter const------identi  er list-|---------------------------------
                          |              -: -|----------- parameter type--   |
                          -       -  -       -array--of---                -|
 - ------------------------identi- er-:-parameter type-=--default paramet-er  value
___________________________________________________________________

A constant argument is passed by reference if it's size is larger than a pointer. It is passed by value if the size is equal or is less then the size of a native pointer. This means that the function or procedure receives a pointer to the passed argument, but it cannot be assigned to, this will result in a compiler error. Furthermore a const parameter cannot be passed on to another function that requires a variable parameter. The main use for this is reducing the stack size, hence improving performance, and still retaining the semantics of passing by value...

Constant parameters can also be untyped. See section 10.3.2, page 355 for more information about untyped parameters.

As for value parameters, constant parameters can get default values.

Open arrays can be passed as constant parameters. See section 10.3.5, page 358 for more information on using open arrays.