[Xotcl] Re: 0.84 mixin behaviour changed ??
Gustaf Neumann
neumann@wu-wien.ac.at
Tue, 13 Mar 2001 10:40:02 +0100
On Tuesday 13 March 2001 10:27, Zoran Vasiljevic wrote:
> Hi !
>
> I strongly suspect that in0.84 version,
> the mixin process is changed, which
> brings some incompatibilities.
yes, the initialization of per-object mixins changed, and it
is documented in the changelog (i inserted an exclamation mark
before the item to denote the potential incompatibility) and in
the tutorial. i have removed now the obsolete part from the
language reference and rewrote the section in the tutorial
more explicit as follows:
----
Note, that the constructors (init methods) of per-object mixins (and
per-class mixins) are only called, if the mixin is registered already during
object initialization (when init is called). For per-object mixins, one can
achieve the initialization of a mixin via an idiom like
Object o -mixin M -init
that registers the mixin before init is called. When a mixin is registered
after object creation and it needs initializations, it is neccessary to
define special methods for this. Note, that the behavior described here is
introdoced in version 0.84 to ensure consistent behavior of intrinsic
classes, per-object and per-class mixins, and to achieve predictable
behavior for dynamic registration for all kind of mixins, and as well during
recreations of objects having mixins registered. Older versions used
heuristics for the initialisation of per-object mixins.
----
For your example below, i would recommend to use a per-class
mixin "... A instmixin B" since the intension is obviously to register
the mixin for each instance of Class A
hope, this clarifies
best regards
-gustaf neumann
> Please consider this simple example
>
> Class A
> Class B
>
> A instproc init {args} {
> [self] instvar C
> [self] mixin B
>
> set C(Aelement) 1
> }
> B instproc init {args} {
> [self] instvar C
> set C(Belement) 1
> }
>
> A instproc foo {args} {
> puts "[self] A bar"
> }
> B instproc foo {args} {
> puts "[self] B bar"
> }
>
>
> The 0.83 behaviour...
>
> % A a
> % a foo
>
> ::a B bar
>
> % a array get C
> Belement 1 Aelement 1
>
>
> The 0.84 behaviour
>
> % A a
> % a foo
>
> ::a B bar
>
> % a array get C
> Aelement 1
>
>
> WHERE is the "Belement" ??????
> It seems that 0.84 does not properly calls the "init"
> on the B class before doing an mixin ?
> Or am I missing something completely?
> Any ideas ?
>
>
> Cheer's
> Zoran Vasiljevic
> Archiware
>
> _______________________________________________
> Xotcl mailing list - Xotcl@wi.wu-wien.ac.at
> http://wi.wu-wien.ac.at/mailman/listinfo/xotcl