14.2 Function declaration

A function declaration defines an identifier and associates it with a block of code. The block of code will return a result. The function can then be called inside an expression, or with a procedure statement, if extended syntax is on.

_________________________________________________________________________________________________________
Function declaration

--function-declaration- function- header-;- subroutine- block -;--------------

 --function-header- function -dotted-identifier -|------------
                      -                -<template-list>-
----formal- parameter- list : result- type-------------hint- directives ---------
                                   modifiers

--result- type type-identifier -----------------------------------------

--subroutine- block -|-----block--------------------------------------
                |-external- directive-|
                |---asm-block----|
                 ----forward------
___________________________________________________________________

The result type of a function can be any previously declared type. contrary to Turbo Pascal, where only simple types could be returned. Note that functions can be generic, see section 8.5, page 491 for more details.

Just as procedures, functions can have hint directives (section 1.5, page 53):

function something : string; deprecated;