[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
MI in SELF
I'm in the SELF group here at SUN.
What you seem to be asking for is sometimes called "behavioral reflection:"
the ability of an object to define for itself how messages are looked up.
It isn't clear from your message what you want to express that seems to
require behavioral reflection. I think there may be ways to use dynamic
inheritence to achieve the result you have in mind, by dynamically re-ordering
chains of parents. Is the problem that you *cannot* order the parents
uniquely? For example, if two parents p1 and p2 both have slots with
names m1 and m2 AND you want p1's m1 behavior but p2's m2 behavior, then
the parents would have to be re-ordered for each message. If that is
your problem, you have several alternatives:
a. re-factor your behavior into smaller chunks
b. use a "transparent forwarder" object (an object that
catches "undefinedSelector" and re-sends the message
to the appropriate object). this is pretty close to
what you seem to want
c. use the reflective facilities to build an object with
the right set of slots (Borning used this technique to
implement multiple inheritance in Smalltalk)
I believe that, however it is implemented, the ability to change an
object's behavior dynamically should be used only sparingly, and in
highly stylized ways. Otherwise, one can too easily create objects
whose behavior is difficult or impossible to predict.