Yet More on MI
Hans-Dieter.Dreier@materna.de
Hans-Dieter.Dreier@materna.de
Mon, 22 Mar 1999 11:56:08 +0100
--D5f2BfGb5zHk4JD76kZelYewny1dmeQL
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable
>Hans-Dieter.Dreier@materna.de wrote:
>
>> The proposed instance layout would be:
>> =
>> this -> - Reference to MI class if used as mixed-class, pointer to this
>otherwise (Note a)
>> - Reference to vtable (Note b)
>> - Reference to ttable (Note c)
>> - (Instance items if any)
>> =
>> Note a:
>> If a reference to this is used in the program itself, a reference to the=
MI
>object is wanted rather than a reference to the mixin object.
>> That's what this instance item is good for.
>> ... =
>> Note c:
>> For each vtable entry this table will contain the this pointer that need=
s to
>be used with that entry
>> (ie he reference to the instance that actually contains the item).
>> If the item is taken from the MI class, it will be a pointer to the MI
>class's instance;
>> if it was taken from a mixin (of the MI class) it will be one to that
>mixin's instance.
>> Because it contains this's, I'll call it the "ttable".
>> The value will be used as a this pointer for actual item access (for vir=
tual
>calls; simple data accesses may not need it).
>
>> This makes sure that a method will always be called with the proper
>> this value (ie consistent with instance layout) which for mixins is
>> different from the MI object's this value.
>
>Normally I would expect this to mean the object no matter whether I'm
>using the mixin or not.
>
The programmer only has access to "this" of Note a which is what you "norma=
lly would expect", ie. this =3D=3D pointer the composite object even if use=
d inside a mixin. But to actually *access* instance items of the mixin, the=
compiler would use the pointer to the start of the mixin. Unless we decide=
to explicitly allow it, the programmer has no access to the start of the m=
ixin itself (Most likely allowing it would do no harm, but we should carefu=
lly consider it).
For all non-mixin cases, both are the same, of course.
You see, this is mainly an implementation issue and (if we decide so) compl=
etely transparent to the program. The user might notice only during debuggi=
ng.
> Matthew Tuck - Software Developer & All-Round Nice Guy
> mailto:matty@box.net.au (ICQ #8125618)
> Check out the Ultra programming language project!
> http://www.box.net.au/~matty/ultra/
--
Regards,
Hans-Dieter Dreier
(Hans-Dieter.Dreier@materna.de)=
--D5f2BfGb5zHk4JD76kZelYewny1dmeQL
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable
IDENTIFIKATIONSANGABEN:
a14629a.txt IA5 DX-MAIL X.400 User Agent=
--D5f2BfGb5zHk4JD76kZelYewny1dmeQL--