No registered users in community xowiki
in last 10 minutes
in last 10 minutes
[Xotcl] Issue with mixin delete
From: Scott Gargash <scottg_at_atc.creative.com>
Date: Mon, 1 May 2006 16:35:26 -0600
Hello,
I've run into an issue when trying to remove a mixin from an object. It appears that removing a
mixin from an object interacts with the method chaining, such that the "next" isn't invoked.
Here's an example:
Class Mixin1
Mixin1 instproc destroy {args} {
puts "Mixin1 1: [my info mixin]"
next
my mixin delete ::Mixin1
puts "Mixin1 2: [my info mixin]"
}
Class Mixin2
Mixin2 instproc destroy {args} {
puts "Mixin2 1: [my info mixin]"
my mixin delete ::Mixin2
puts "Mixin2 2: [my info mixin]"
next
}
Class Mixin3
Mixin3 instproc destroy {args} {
puts "Mixin3 1: [my info mixin]"
my mixin delete ::Mixin3
puts "Mixin3 2: [my info mixin]"
next
}
Object a
puts "a: [a info mixin]"
a mixin set {::Mixin1 ::Mixin2 ::Mixin3}
puts "a: [a info mixin]"
a destroy
And the output is
a:
a: ::Mixin1 ::Mixin2 ::Mixin3
Mixin1 1: ::Mixin1 ::Mixin2 ::Mixin3
Mixin2 1: ::Mixin1 ::Mixin2 ::Mixin3
Mixin2 2: ::Mixin1 ::Mixin3
Mixin1 2: ::Mixin3
Because Mixin1 invokes "next" before "mixin delete", Mixin2's "destroy" method gets invoked. But
since Mixin2 invokes "mixin delete" before "next", Mixin3's "destroy" method is not invoked, despite
it remaining in the object's list of mixins.
This is not the behavior I would expect, and I can't find it documented anywhere. Is this the
intended behavior? What should I do if I want to remove a mixin and then continue executing chained
methods.
Scott
Notice
The information in this message is confidential and may be legally privileged. It is intended
solely for the addressee. Access to this message by anyone else is unauthorized. If you are not
the intended recipient, any disclosure, copying or distribution of the message, or any action
taken by you in reliance on it, is prohibited and may be unlawful. If you have received this
message in error, please delete it and contact the sender immediately. Thank you.
Date: Mon, 1 May 2006 16:35:26 -0600
Hello,
I've run into an issue when trying to remove a mixin from an object. It appears that removing a
mixin from an object interacts with the method chaining, such that the "next" isn't invoked.
Here's an example:
Class Mixin1
Mixin1 instproc destroy {args} {
puts "Mixin1 1: [my info mixin]"
next
my mixin delete ::Mixin1
puts "Mixin1 2: [my info mixin]"
}
Class Mixin2
Mixin2 instproc destroy {args} {
puts "Mixin2 1: [my info mixin]"
my mixin delete ::Mixin2
puts "Mixin2 2: [my info mixin]"
next
}
Class Mixin3
Mixin3 instproc destroy {args} {
puts "Mixin3 1: [my info mixin]"
my mixin delete ::Mixin3
puts "Mixin3 2: [my info mixin]"
next
}
Object a
puts "a: [a info mixin]"
a mixin set {::Mixin1 ::Mixin2 ::Mixin3}
puts "a: [a info mixin]"
a destroy
And the output is
a:
a: ::Mixin1 ::Mixin2 ::Mixin3
Mixin1 1: ::Mixin1 ::Mixin2 ::Mixin3
Mixin2 1: ::Mixin1 ::Mixin2 ::Mixin3
Mixin2 2: ::Mixin1 ::Mixin3
Mixin1 2: ::Mixin3
Because Mixin1 invokes "next" before "mixin delete", Mixin2's "destroy" method gets invoked. But
since Mixin2 invokes "mixin delete" before "next", Mixin3's "destroy" method is not invoked, despite
it remaining in the object's list of mixins.
This is not the behavior I would expect, and I can't find it documented anywhere. Is this the
intended behavior? What should I do if I want to remove a mixin and then continue executing chained
methods.
Scott
Notice
The information in this message is confidential and may be legally privileged. It is intended
solely for the addressee. Access to this message by anyone else is unauthorized. If you are not
the intended recipient, any disclosure, copying or distribution of the message, or any action
taken by you in reliance on it, is prohibited and may be unlawful. If you have received this
message in error, please delete it and contact the sender immediately. Thank you.