Menu

Interface Declarations

Mark Anthony Taylor (Shyreman)

Interfaces are sets of method references(functions that imply a class). All interfaces are public
objects, and they must be created within a namespace thus:

(interface <fully-qualified-interface-name>
    (method1...methodN)
)

Where <fully-qualified-interface-name> is a namespace prefixed interface name separated with a period
character. The right most name must begin with a capital letter A-Z and is followed by a series of
alpha numeric characters of any case A-Z a-z and 0-9.

Example:

(interface Sys.IOneToOneF32
    (Invoke (Float32 x) -> (Float32 y))
)

The interface above IOneToOneF32, is published in the Sys namespace and implements one method
called Invoke that maps a floating point value x to another floating point value y. Notice that methods
defined in the interface definition do not include a body. Bodies are defined by implementing a method
in a class's module file.

Interfaces can inherit from other interfaces by specifying a base interface in an extends clause:

(interface Sys.IOneToOneF32Ex
    (extends Sys.IOneToOneF32)
    (InvokeEx (Float32 x)->(Float32 y))
)

In this case Sys.IOneToOneF32Ex is built upon the Sys.IOneToOneF32 interface and adds a method
InvokeEx to it.


Related

Wiki: Content