method ::= [ 'stream' | 'procedure' ] identifier [ '(' parameters ')'
] [ ':' result_type ] 'is' method_body 'end'.
parameters ::= parameter_specification ( ';' parameter_specification )\stern .
parameter_specification:= [ parameter_kind ] attribute_specification .
method_body ::= block | 'abstract' | 'external' identifier [ string_constant ].
block ::= local_declarations statements .
For statements see section 6, for expressions
see 7.
Example: stream elts : T pre not empty is ...end
divmod(!arg:INT; :div,mod:INT) is ...end
combine(a,b:procedure(INT):INT):procedure(INT):INT is ...end
Methods are procedures or stream methods. They are given by a block, the method body. They may be called by using their name in a statement or expression. The parameters of methods correspond to the arguments of method calls, cf. 2.1.4 and 6.7. Bound methods are established by a (partial) call and can then be used like a method.
Stream methods are (a limited form of) coroutines and mostly have the same form as procedures. Additionally they may contain the keyword resume as a statement. Stream methods are used for establishing a bound stream or a stream object.
A method which is called in an expression must deliver a result. The method declaration must then specify a result type. In this case the method will automatically contain a local variable res of the result type. The result of a procedure call is the value of res. Procedures with results are also called procedures. Other procedures are called (proper) procedures. Similarly the value of res is transmitted to the caller whenever a resume-statement is executed in a stream call.
A method body abstract may only appear in an abstract or an external class. A method body external may only appear in an external class. The identifier denotes the foreign language, the optional string constant defines the linker symbol to be used. The default is class_feature where class is the name of the external class and feature is the name of the declared feature.