2013-12-09

type.tags for aggregates

10.17: adda/oop/type.tags for aggregates:
[12.8: intro:
. if we were to have a generic aggregate,
what would its type.tag look like?
(the purpose of a generic aggregate
is having something that packs objects together,
and can be easily created and traversed .

. it starts with the systemtype.tag,
that indicates what system type this object is:
(tuple, subtype array, supertype array,
pointer, value, subprogram, task, ..);
# if a tuple:
. after the systemtype.tag,
there is a word for size of an array,
then an array of relative pointers
that show how much further down in the block of mem
a particular object is located;
each object starts with its supertype.tag,
and then also will have a subtype.tag .
# if a supertype array:
(all items share the same supertype.tag
but they have differing subtypes,
and thus may have differing sizes)
. after the systemtype.tag,
there is a word for size of an array,
a word for the shared supertype.tag,
then an array of relative pointers
that show how much further down in the block of mem
a particular object is located;
each object has a subtype.tag
but doesn't have its own supertype.tag .
# if a subtype array:
(the items all share the same subtype.tag
as well as the same supertype.tag,
so they will all have the same size)
. after the systemtype.tag,
there is a word for size of an array,
a word for the shared supertype.tag,
and a word for the shared subtype.tag,
then the array of the same-size items,
each having neither a supertype.tag
nor a subtype.tag .

. the generic aggregate is usually assigned to
an any.type variable,
and this var's location determines its home act'rec .

. the first ideas I had are obsolete:
idea#2:
. basically you need just about everything
that is needed by the tuple's declaration!
but, if the object exists, its type was declared;
and our type.tag can just point to that .
idea#1: ]
. the aggregate type.tag can be
either a tuple or array;
to tell the difference, look at the byte after it:
if 0 then it's an array;
look after # of types of an array
and there is the # of objects .
. if the # of types is negative,
it is then negated and becomes
the high byte of a 15bit number,
to support the few tuples that have
more than 255 components .
. in the case of the array (vs tuple)
since the code for array's # of types is just 0,
the size is always a byte,
and the next 3 bytes can be
a 24bit # of array items .
. if # of types = 1,
then the aggregate is a variant tuple .
.. variants can be nested,
so the type.tag is a tree?
need to study what sort of
variant tuples we want to support
before we can decide how to encode them .
12.8:
. generic tuples are all about variance,
and the top design (idea#3) handles any variant .

No comments:

Post a Comment