Function Definition

function-definition = expression-function | instruction-sequence-function

expression-function = 
  name ( name {name} ) `=' expression
  
instruction-sequence-function = 
  func name [( parameter-declarations )] -> type-expression
    {instruction}
  [endf]

parameter-declarations = 
  name {, name} [: type-expression [; parameter-declarations]]

Functions defined as a sequence of instructions may only appear at the global level. In other words, such functions cannot be defined local to another function or procedure, nor nested inside a selection or loop instruction. Note that the syntax allows the start of a function or procedure definition to implicitly end the definition of the preceding procedure or function.

Like any name, function names can be used in expressions. When used in an expression, a function name results in a value of type

  map from T1, T2, .., Tn-1 to Tn

where T1, .., Tn-1 are the types of the function parameters and Tn is the type of the value returned by the function. Parameter names which are not explicitly typed, are of type Entity.

Note that every definition of a function generates a value distinct from all others. In other words, even if two function definitions are identical, the values their names result in when used in expressions are not equal.

See also: function call, map.


Herman Venter

This is Slim documentation as snarfed on 27 May 1999 by dB.