A Tour of Morfa

Structs, classes and interfaces

Morfa supports object-oriented programming based on 3 kinds of user-defined types: structs, classes and interfaces. In short:

  • structs live on the stack, are passed by value and act a bit like primitive types (like int)

  • classes live on the heap, allow for polymorphism, can have null value and are passed by reference

  • interfaces do not have member data nor implementation, they state the behaviour a deriving class must provide.

Thus Morfa structs are similar to C structs, while Morfa classes and interfaces are similar to Java or C# classes and interfaces.

Structs, classes and interfaces are also called aggregate types, since they aggregate their member data.