Methods of Classes
Methods are internal procedures of a class that determine the behavior of an object. They can access all the attributes of all instances of their class and can therefore change the status of an object. Methods have a parameter interface, used by the system to pass values to them when they are called, and by which they can return values to the caller. The private attributes of a class can only be changed using methods of the same class.
meth is declared in the
of a class using the statements
CLASS-METHODS and implemented in the
implementation part of the class using the following
As in all procedures, local data types and data objects can be declared in methods. Methods are called
statically using the expression
meth( ... ) or
dynamically using the
CALL METHOD (known as a dynamic invoke).
In the methods of a class, one method of the class obscures a built-in function with the same name. This done regardless of the type and number of method parameters and the type and number of arguments on the function. This means that a method should not have the same name as a built-in function.
Instance methods are declared using the statement
METHODS. They can access all the attributes of a class and can trigger all its events.
Any attempt to use an initialobject reference variable to call an instance method raises a catchable exception.
As well as the regular methods that are called explicitly,
there are two special methods called
class_constructor. These are called automatically when an object is created or when a class component is accessed for the first time.
Functional methods are methods with precisely one
RETURNING parameter and any number of other formal parameters. Functional methods cannot just be called as
standalone statements, but also as
functional method calls in
operand positions for functions and expressions. Here they can be also be combined as
In interfaces, methods can be made optional using the addition
DEFAULT of the statements
CLASS-METHODS. An optional
interface method does not need to be implemented explicitly in a class when an interface is implemented.
Instead, a default behavior is specified for calls of non-implemented methods in the definition.
DEFAULT IGNORE calls an empty method and
DEFAULT FAIL raises an exception.