The Freya Programming Language

Interface types

See also

An interface is a reference type that specifies a contract. You cannot create an object from an interface type, since an interface does not provide any implementation. Interface types must be implemented by classes and records.

Interface declarations

Interface declarations follow these rules:

Interface types may include generic type parameters:

IEquatable = interface[T]
    method Equals(Other: T): Boolean;
end;

Actually, many important interface types from the .NET framework are declared generics, starting with .NET 2.0.

Interface inheritance

An interface type may inherit features defined by one or more base interfaces. A common example is the generic IEnumerable interface:

IEnumerable = interface[X](System.Collections.IEnumerable)
    method GetEnumerator: IEnumerator[X];
end;
ISymbolTable = interface(ITypeMap, IErrorManager)
    // ...
end;

See also

The Freya Programming Language
Type declarations
Class declarations
Implementing an interface
Interface delegations