Function declaration

Function is a named group of instructions meant to be executed in succession and belongs to an Object. In that respect it is just like an Action. The diference is that while Action belongs to a particular state of the object, Function belongs to the object as a whole. Another diference is their invocation. Action is invoked from outside the object by DO instructions in other objects or external commands by placing the action on the object's action queue, while on the other hand Function is invoked from other actions of the same object by CALL instruction and is executed immediately as part of those actions.

Functions are declared just after Parameters declaration of the object. (see below) The declaration of a function begins with the keyword Function followed by a colon.
Then follows the function's name. This has to be unique among the object's functions. It can however coincide with one of the object's actions.

Function can accept parameters in the same way as an action. When the function has parameters then parameter declaration will follow. More about parameters-declaration see Parameters in SMI.

Function Declaration Syntax:

Function: function-name [( parameters-declaration )]

SML Instructions


Placement of Function Declarations

Object : obj-name Parameters : .... Function : fun1 ... Function : funi ... Function : funn ... State : state1 ...