2012-02-29

multi-inheritance

2.20: adda/oop/multi-inheritance:

. the essence of what a call to the supertype does
is manage its own ivars (instance vars)
during alloc, init, dealloc;
so, when you multi-inherit, then your call to super is
sent to each parent class .
. self`super(function)
-- this would be a good syntax because
  it shows the self is being modified by a super function
  which takes as arg, self and a function to send to supers .

. so how does each supertype in a multi-inheritance
know where its ivars are within the given obj?
. the first part of the object
has to be a dictionary of classes that
tells each super where their ivars are located .

. in the most general form of oop operation
there are 2 type tags:
# which type among all unrelated types:
(eg, is it a character string or a number?);
# within a type, which subtype it is:
(eg, is the number an integer, float, or quotient?).

supertype.tags can be implicit:
. we can save space in a var's storage
by ensuring that it's always assigned
values of a particular type
so that the type tag is no longer needed
because the owning subprogram's symbol table
already has it .
. if, according to the symbol table,
this object is typed,
then we can expect that
only that type has been assigned;
if not, we can expect only that
the field#(-1) will be a supertype ID .
[2.29:
. now, the next job for multi-inheritance,
is accepting a message for a function to execute .
. the type mgt who accepted the multiple inheritances
was the final determiner of what a message means;
so, for example if type mgt inherits religious and hungry,
but they both implement [pass the bread],
then the type mgt in this case has to decide,
should [pass the bread] be sent to hungry, to religious,
or overridden to do something integrated ?
. thus there are 2 fixed fields in an obj:
# the dictionary of supers' ivars,
# the type mgt ID, that gets sent the message .]