No registered users in community xowiki
in last 10 minutes
in last 10 minutes
Re: [Xotcl] Precedence Order
From: Gustaf Neumann <neumann_at_wu-wien.ac.at>
Date: Mon, 04 Sep 2006 11:50:42 +0200
Scott,
you can achieve the precedence you are wanting by adding multiple
superclasses to Derived.
In the forthcoming version (which will be named 1.5), you can even use
"superclass add" like
in the following example.
Class create Base
Class create Derived -superclass Base
Derived d
puts [d info precedence] ;# ==> ::Derived ::Base ::xotcl::Object
Class create BaseMixin
Derived superclass add BaseMixin
puts [d info precedence] ;# ==> ::Derived ::BaseMixin ::Base
::xotcl::Object
the new release is already passing the regression test. i will do some
more test
with the aolserver+OpenAce and make it available rsn.
best regards
-gustaf
Scott Gargash schrieb:
>
> 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
>
Date: Mon, 04 Sep 2006 11:50:42 +0200
Scott,
you can achieve the precedence you are wanting by adding multiple
superclasses to Derived.
In the forthcoming version (which will be named 1.5), you can even use
"superclass add" like
in the following example.
Class create Base
Class create Derived -superclass Base
Derived d
puts [d info precedence] ;# ==> ::Derived ::Base ::xotcl::Object
Class create BaseMixin
Derived superclass add BaseMixin
puts [d info precedence] ;# ==> ::Derived ::BaseMixin ::Base
::xotcl::Object
the new release is already passing the regression test. i will do some
more test
with the aolserver+OpenAce and make it available rsn.
best regards
-gustaf
Scott Gargash schrieb:
>
> 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
>