DEFINTERFACE

General form:

Introduction

DEFINTERFACEs are collections of ABSTRACT DEFMETHODs.

A DEFCLASS may specify that it IMPLEMENTS one or more DEFINTERFACEs, in which case it must have DEFMETHODs matching those in the INTERFACEs.

DEFINTERFACEs may be used as types. Instances of DEFCLASSes implementing an INTERFACE are acceptable wherever the INTERFACE is required.

Example

 00010 $COMPLIANCE 3
     : 'main()
     : END
     : 
     : DEFINTERFACE printable
     :     ABSTRACT DEFMETHOD print()
     : END INTERFACE
     : 
     : DEF CLASS cls IMPLEMENTS printable
     :     FLD n
     :     DEFMETHOD print()
     :         PRINT $PRINTF("%d", this->n)
     :     END METHOD
     : END CLASS
     : 
     : DEFSUB 'PrintPrintable(p AS printable)
     :     p->Print()
     : END SUB
     : 
     : DEFSUB 'main()
     :     LOCAL DIM c AS cls = NEW cls
     :     c->n = 4
     :     
     :     'PrintPrintable(c)
     : END SUB