[self-interest] Re: KNOW TYPES
Jecel Assumpcao Jr
jecel at lsi.usp.br
Wed Sep 8 19:21:43 UTC 1999
> Does Self has got any menssage or intruction to know
> the type ( integer, char...) of an slot in run-time?
Let's start with some definitions:
- container type: a container is a slot, or instance variable or
other kind of variable which can hold an object or a reference
(pointer) to an object. If the container can hold some objects
but not others, we can say that it has a certain type.
- object type: the object includes data that forms its state. If,
in addition to that it also includes explicit information about
its type we can say it is a "runtime typed object".
- abstract type: each object can receive a set of messages, but
will fail if sent different ones. This set of messages that it
understands defines its "interface" or abstract type.
- concrete type: each object's state is represented in a certain
way in the machine, and there are a set of low level routines
that can manipulate it, but other routines would give the wrong
results if applied to the state.
In practice, the word "type" is used in all these sense to
varying degrees when talking about programming languages.
- abstract container type: it is only implied. By looking at
what messages will be sent to an object stored in a given slot,
you have an informal definition of what type of object it must
be (you can invoke Ole Agesen's type inferencing software to
obtain this information automatically, but it is not part of
the base Self system)
- concrete container type: doesn't exist
- concrete object type: inside the virtual machine, there are
C++ objects called "maps". A pointer to this map from an object
is its concrete object type, but this is not accessible from
the Self level
- abstract container type: the class declared for the variable,
since multiple inheritance has complex relocation schemes which
interact with the vtable at runtime
- concrete container type: the class declared for the variable,
since all subclasses' data format must be an extension of the
- concrete object type: vtable
- abstract container type: the interface declared for the variable
- concrete container type: the class declared for the variable
- concrete object type: a pointer to the class structure
I hope this isn't too much more than you wanted to know :-)
Anyway, you can't know the concrete types for slots, you can
know the abstract type of a slots with a very complex (and not
included) application program and you can know the object type
for some object that happens to be contained in some slot at
some given time by creating a mirror for it and asking about
(reflect: someSlot) isReflecteeInteger
Does this help at all? Like Douglas said, if you need something
like this you probably have some design problems.
In another message, Douglas Atique wrote:
> Of course, in Self a slot has a "type", which is a different concept:
> a slot can be a data slot, a method slot, a parent slot, an argument
Maybe we should use the word "kind" to avoid being even more confusing
than I have been up to now ;-)
I would say there are data slots, constant slots, method slots and
argument slots. And any of them can be a parent slot or not.
More information about the Self-interest