Description
Function identifiers are identifiers that have been associated with a function using a function declaration.
Example
Here is an example of a function declaration.
//This function checks whether a files exists. Actually it really checks
//to see if a file can be opened for reading without causing an error,
//which is usually the same thing. The function first turns off run-time error
//trapping so that if an error occurs it can be retrieved with getlasterror
//rather than causing the program to halt. Then the function attempts to
//open the file for reading. If no errors occur then the file is closed and
//the file must exist. If an error occurs then the function assumes the file
//does not exist. In either case error trapping it turned back on before the
//function exits.
function FileExists(name : filename) : boolean;
var
f : text;
begin (* FileExists *)
traperrors(false);
reset(f, name);
if getlasterror=0 then
begin
close(f);
FileExists := true;
end
else
FileExists := false;
traperrors(true)
end; (* FileExists *)
Syntax
(NOTE: for clarity some parts of the syntax are omitted, see Irie Pascal Grammar for the full syntax):
function-declaration =
function-heading ';' directive |
function-identification ';' function-block |
function-heading ';' function-block
block = declarative-part statement-part
compound-statement = 'begin' statement-sequence 'end'
declaration-group =
label-declaration-group |
constant-definition-group |
type-definition-group |
variable-declaration-group |
function-declaration |
procedure-declaration
declarative-part = { declaration-group }
directive = forward-directive | external-directive
formal-parameter-list = '(' formal-parameter-section { ';' formal-parameter-section } ')'
formal-parameter-section = value-parameter-specification |
variable-parameter-specification |
procedure-parameter-specification |
function-parameter-specification
function-block = block
function-heading = 'function' identifier [ formal-parameter-list ] ':' result-type
function-identification = 'function' function-identifier
function-identifier = identifier
function-parameter-specification = function-heading
identifier = letter { letter | digit }
identifier-list = identifier { ',' identifier }
procedure-heading = 'procedure' identifier [ formal-parameter-list ]
procedure-identification = 'procedure' procedure-identifier
procedure-identifier = identifier
procedure-parameter-specification = procedure-heading
result-type = type-identifier
statement-part = compound-statement
statement-sequence = statement { ';' statement }
type-identifier = identifier
value-parameter-specification = identifier-list ':' type-identifier
variable-parameter-specification = 'var' identifier-list ':' type-identifier