4.4. Routine definitions

Example 4-6. Examples:

a(f:FLT):FLT
pre f>1.2      
post result<4.3
is ... end;
b is ... end;
private d:INT is ... end;
c(s1,s2,s3:STR) is ... end
routine_definition ==>
        [ private ] identifier [ ( routine_argument { , routine_argument } ) ] [ : type_specifier ] [ pre  expression ] [ post expression ] [ is statement_list end ]

A routine definition may begin with the keyword 'private' to indicate that the routine may be called from within the class but is not part of the class interface. The identifier specifies the name of the routine.

If a routine has arguments, the declaration list is enclosed in parentheses. The mode, name and type of each argument is specified in this list. The types of consecutive arguments may be declared with a single type specifier. Each argument's mode defaults to 'in' if neither 'out' nor 'inout' is specified (See Modes). If a routine has a return value, it is declared by a colon and a specifier for the return type. SAME is permitted only for a return type or out arguments.

The 'pre' and 'post' clauses specify optional pre- and post-conditions, and are discussed further on See Safety Features. The body of a routine definition is a list of statements (See Basic Statements).