Eve Inheritance
A class can extend one or more classes: it receives their attributes and methods, and can add or replace them. All the classes form a tree whose root is
Object.Inheritance
Eve support multiple inheritance and polymorphism. You can specify one or more supertypes after the inheritance operator in a list. This is the "inheritance" symbol. It can define a new class that inherits all attributes and methods of the super-classes or base-class.
Pattern:
** define a BaseType for inheritance without a superclass
class BaseType = {attribute};
** define an abstract class without attributes
class AbstractType <: Object is
** abstract method to be implemented
method demo(parameters) => (result:Type);
end AbstractType;
** create a descendent of BaseType and AbstractType
class NewType += {new_attribute} <: (AbstractType, BaseType) is
** class members
...
** implement abstract method
method demo(parameters) => (result:Type) is
...
return;
** constructor for the new class
constructor(param1, param2) => (@self) is
** BaseType has no constructor: it is filled by name
let self := BaseType(attribute: param1);
let self.new_attribute := param2;
...
return;
end NewType;
Class Tree
Using the "Object" as the "root class", you can create a hierarchy of classes. Each classes is derived from the Object or from other "superclass" forming a "class tree". Like a real tree the class hierarchy has a single root in this picture. However Eve supports multiple roots.
Class Tree
Read next: Generics