INTERFACE (class behavior definition)

Top 

 

label

INTERFACE ( [ parentinterface ] ) [, TYPE]

 

    [methods ]

 

END

INTERFACE

A collection of methods to be used by the class that implements the interface.

parentinterface

The label of a previously declared INTERFACE structure whose methods are inherited by the new INTERFACE. This may be an INTERFACE with the TYPE attribute.

TYPE

Specify the INTERFACE is only a type definition. TYPE is implicit on an INTERFACE but may be explicitly specified.

methods

PROCEDURE prototypes

An INTERFACE is a structure, which contains the methods (PROCEDUREs) that define the behavior to be implemented by a CLASS. It cannot contain any property declarations. All methods defined within the INTERFACE are implicitly virtual. A period or the END statement must terminate an INTERFACE structure.

Derived INTERFACEs (Inheritance)

An INTERFACE declared with the parentinterface parameter creates a derived interface that inherits all the methods of the named parentinterface. The derived interface may also contain its own methods.

Any method prototyped in the derived interface with the same name as a method in the parentinterface overrides the inherited method if both have the same parameter lists. If the two methods have different parameter lists, they create polymorphic functions in the derived interface that must follow the rules of Procedure Overloading.

VIRTUAL Methods (Polymorphism)

All methods in an INTERFACE are implicitly virtual, although the virtual attribute may be explicitly specified for clarity.

VIRTUAL methods in the derived interface may directly call the parentinterface method of the same name by prepending PARENT to the method's name. This allows incremental derivation wherein a derived interface method may simply call up to the parentinterface method to perform its functionality, and then extend it for the requirements of the derived interface.

Method Definition

The PROCEDURE definition of a method (its executable code, not its prototype) is defined by the CLASS that is implementing the INTERFACE. All methods for an interface must be defined in the IMPLEMENTING class.

Referencing INTERFACE methods in your code

You must call the methods of an INTERFACE by using dot notation syntax (by prepending the label of the CLASS to the label of the INTERFACE to the label of the method).

For example, using the following INTERFACE and CLASS declaration:

MyInterface INTERFACE

MyProc       PROCEDURE

          END

MyClass     CLASS,IMPLEMENTS(MyInterface)

           END

You may call the MyProc PROCEDURE as:

CODE

MyClass.MyInterface.MyProc

 

See Also:

IMPLEMENTS

IMPLEMENTS inheritance