CONTENTS | PREV | NEXT
14B. object inheritance
-----------------------
it's always annoying not being able to express dependencies between
OBJECTs, or reuse code that works on a particular OBJECT with a bigger
OBJECT that encapsulates the first. Object Inheritance allows you
to do just that in E. when you have an object a:
OBJECT a
next, index, term
ENDOBJECT
you can make a new object b that has the same properties
as a (and is compatible with code for a):
OBJECT b OF a
bla, x, burp
ENDOBJECT
is equivalent to:
OBJECT b
next, index, term /* from a */
bla, x, burp
ENDOBJECT
with DEF p:b, you can directly not only access p.bla as usual,
but also p.next.
as an example, if one would have a module with an OBJECT to
implement a certain datatype (for example a doubly-linked-list),
and PROCs to support it, one could simply inherit from it, adding
own data to the object, and use the _existing_ functions to
manipulate the list. However, it's only in combination with
methods (descibed below), inheritance can show its real power.