2.1 Interfaces
Objects have types which are called interfaces. You can define an interface like this:
interface Person { get_name : 1 -> string; get_age : 1 -> int; set_age : int -> 0; }
An interface is nothing more than alias for a record type. In particular the above is equivalent to
typedef Person2 = ( get_name : 1 -> string, get_age : 1 -> int, set_age : int -> 0 );
Now, we can define a person with the interface:
object person (name:string, var age: int) implements Person = { method fun get_name () => name; method fun get_age () => age; method proc set_age (x:int) { age = x; } };
Of course interfaces can be extended:
interface WorkingPerson extends Person { get_occupation: 1 -> string; }