View · Search · Index
No registered users in community xowiki
in last 10 minutes

[Xotcl] Precedence Order

From: Scott Gargash <scottg_at_atc.creative.com>
Date: Tue, 29 Aug 2006 11:21:23 -0600

As I understand it, precedence order is computed as filters then mixins
the superclasses, and this sort order is applied "globally" to an object.

In other words:

Class create Base
Class create Derived -superclass Base
Derived d
d info precedence ==> ::Derived ::Base ::xotcl::Object

Class create BaseMixin
Base instmixin add BaseMixin
d info precedence ==> ::BaseMixin ::Derived ::Base ::xotcl::Object

This behavior seems to violate encapsulation. BaseMixin is intended to
intercept messages to Base. Derived doesn't know about BaseMixin and
BaseMixin doesn't know about Derived, yet BaseMixin ends up being the
first interceptor of messages to Derived.

Since BaseMixin is intended to modify the behavior of Base, it would be
better BaseMixin preceeded Base (and only Base) in the sort order.

d info precedence ==> ::Derived ::BaseMixin ::Base ::xotcl::Object

The current behavior means you can't really add a mixin without
understanding everywhere that the object being extended is used. Is there
some benefit to the current behavior that I don't understand?