Sorry for the vague asking. I will try to make it clearer.
anObject _AddSlots: (| aSlot <- ??method?? |) ?
anObject _AddSlots: (| aSlot = ??method?? |)
I liked to ask how to modify the method which is contained in a slot of an object. If it is contained in a constant slot, we may need to first remove it and add a slot of the same name with a new (different) method. Is this right? Is it no problem to do the above without using the outliner? (If my vague memory is correct, I sometimes failed to do that -- system crash.)
Note that this is an alternative form of reflection. Rather than sending normal messages to a mirror on the object, we are sending a primitive message to the object itself. This works because primitives have access to the "underlying machinery" directly. The reason most Self source files do this kind of thing is that it is a little faster than using mirrors
I understand this, but
and also because mirrors aren't fully functional while the basic "world" is being read in.
would you kindly tell me any pointers to the above problem?
Is this too much a reflective way? In so doing, I have some troubles in the updates of objects (in a recursive use of AddSlots)..
anObject _AddSlots: (| aSlot <- ( anotherObject _AddSlots: ( anotherSlot <- ??anotherMethod |) ) |)
What you did here (if you change the "<-"s to "="s) is to add a method to "anObject" so that "anObject aSlot" will add "anotherSlot" to "anotherObject" every time it is executed. That is a strange thing to do.
Surely I think you feel it strange (my example is silly), but the point is that I like to modify the method in the slot. Doesn't Self allow us to put a method in a DATA slot? I like to execute different methods under the identical slot name.. Probably, there may be a much better way for it.
If you merely what to create several objects nested in each other, you can do this:
anObject _AddSlots: (| aSlot <- (| anotherSlot = ??anotherMethod?? |) |)
In this case, however, "aSlot" is a data slot with an initial value, and not a method.
This would be an answer to what I liked to know. Is this side-effect free? How should I make the method executed? Where is that SLOT "anotherSlot" put?
Hmmm... I probably misunderstood what you are asking. Anyway, you can create nested objects without having to use _AddSlots: at all.
Would you kindly give me some good examples?
Probably, it is strange or useless to modify the method in a slot of an object, but I am caught by it...
Any help to a miserable, confused Self user?
Thank you so much.
a*
self-interest@lists.selflanguage.org