Hi there,
Object instproc insert_mixin {mixin_list} { my mixin [append mixin_list " " [my info mixin]] }
with names like mixinappend, mixinprepend for mixins, filters, instmixins, instfilters we would introduce a large number of methods, which do more or less the same.
what do you people think about the following "interceptor" method: it is more verbous, but much more powerful as well; it allows appending/prepending/inserting at a certain position and deletion of all kinds of interceptors:
================================================ Object instproc interceptor {op kind name {pos 0}} { switch -exact $op { add {my $kind [linsert [my info $kind] $pos $name]} delete { set old [my info $kind] set p [lsearch -glob $old $name] if {$p>-1} {my $kind [lreplace $old $p $p]} else { error "$name not in $old" } } } puts "$kind list: [my info $kind]" }
Class A Class B Class C
Object o o interceptor add mixin A o interceptor add mixin B o interceptor add mixin C end o interceptor delete mixin *A ================================================ The output of this script is:
mixin list: ::A mixin list: ::B ::A mixin list: ::B ::A ::C mixin list: ::B ::C
best regards -gustaf neumann