[Xotcl] problem: filter disappears if instproc redefined
seva@design.kiev.ua
seva@design.kiev.ua
Tue, 26 Dec 2000 21:04:13 +0200 (EET)
Hello
I'm working on real-life application, which controls some hardware
devices throw network protocol.
For now this application consist of several instances of some objects,
which implements FSM (finite state machines) of hardware devices. Now it is
implemented using Itcl, but I need possibility to change fsm
states and implementation without restarting application. Itcl does
not allow me to do this, so I decided to switch to XOTcl.
I split my application in several source files. Each of files
implements one of fsm's or helper functions, and when I need to change logic
of work, i simply source all files.
There are several problems with this:
1) when I execute command Class Some, previous instance of this
class deleted, and all objects move to ::Object class.
This problem I solve by using filter for create command on ::Object (idea
stolen from recoverypoint class :)) ). But with that second problem
arrives:
2) when some instproc used as a filter, and redefined, it's filter become
inactive. (so first problem arrives again, when I source recover.tcl which
has recoverfilter definition)
after setting filter again, all works as expected
Hope for your help :))
Example code:
----------------- a.xotcl -----------------
#!/usr/local/bin/tclsh8.2
package require XOTcl
Object instproc filter {args} {
puts "filter: [self] [[self] info calledproc]"
next
}
Object filter filter
puts "Object test"
Object test
puts "test set a a"
test set a a
puts "Object instproc filter"
Object instproc filter {args} {
puts "new filter: [self] [[self] info calledproc]"
next
}
puts "test set a a"
test set a a
puts "Object filter filter"
Object filter filter
puts "test set a a"
test set a a
-----------------------------------------
Result:
Object test
filter: ::Object test
filter: ::Object create
test set a a
filter: ::test set
Object instproc filter
filter: ::Object instproc
test set a a
^^^^^^^^^^^^^^^ unfiltered
Object filter filter
test set a a
new filter: ::test set
new filter: ::@ destroy
new filter: ::test destroy