Hello everybody:
I have a new question for you: Does Self has got any menssage or intruction to know the type ( integer, char...) of an slot in run-time?
please answer my question as soon as posible and thank you for yuor help.
Maryah.
Hello, Maryah. As far as I know, a slot can't have a type. A slot is just a structure referenced by an object that references another object. After studying the VM implementation, I am convinced that everything is an object in Self. Even strings and numbers. As such, Self encourages you to use polymorphism instead of type information to implement the intended behavior. For example, if you need to know the type of a slot because you want to act conditionally on it, you are on the wrong way. What you need is to embed this behavior in each kind of object you may have so that you don't have to know its "type", but the object will do the right thing when you ask it to. 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 slot (did I miss something?)... Please anyone correct me if there are alternatives! Regards, Douglas
maria wrote:
Hello everybody: I have a new question for you: Does Self has got any menssage or intruction to know
the type ( integer, char...) of an slot in run-time?
please answer my question as soon as posible and thank
you for yuor help.
Maryah.
MyPoints-Free Rewards When You're Online. Start with up to 150 Points for joining! http://clickhere.egroups.com/click/805
eGroups.com home: http://www.egroups.com/group/self-interest http://www.egroups.com - Simplifying group communications
maria wrote:
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.
Self:
- 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
C++
- 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 superclass format
- concrete object type: vtable
Java
- 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 its reflectee:
(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 slot
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.
-- Jecel
self-interest@lists.selflanguage.org