[Xotcl] Issue with mixin delete

Gustaf Neumann neumann at wu-wien.ac.at
Mon May 8 22:15:41 CEST 2006


> BTW, this will happen with any method, not just "destroy". 
>
i know.
>
> Is it not considered acceptable to ever remove a mixin class?  
>
> When is it valid to remove a mixin if removing it corrupts the method 
> chaining? 
>

removing a mixin class from the mixin list does not "corrupt" the chain 
in the sense that there
is a memory corruption etc. The current implementation does not allow to 
remove
***active*** mixin classes, this are the classes of which the method is 
currently executing.

what does this mean, assume there are classes M1, M2, M3, all of the form

Class M2
M2 instproc foo {} {
    BEFORE
    next
    AFTER
}

Object o -mixin {M1 M2 M3}

when method foo of M2 is called, M2 is the active call. If between the 
invocation
of foo of M2 and "next" the  mixin class M2 is removed for o, "next" has the
problem to find the continuation (next searches the current mixin 
classes of o
for the currently executing Class). If this class is not found (your 
example),
the list is searched to the end and no other Mixin classes are searched.

So, the only restriction is that you are not allowed to remove the mixin 
from o
in the BEFORE part of M2. If you remove M2 from the BEFORE part of
M1, there won't be a problem, since foo of M2 won't be called. If you remove
M2 in AFTER of M2 foo, there would not be a problem either, since "next"
was alreday executed.

It looks quite easy to give a reasonable error message, when the 
currently active
mixin class is deleted, it will be more expensive to handle this problem in
a friendly way.

Hope, this explains, what is happening.

-gustaf

PS: wouln't be conditional mixins a solution for your problem?



More information about the Xotcl mailing list