Dear XOTcl-guys! The script below illustrates what I consider to be an XOTcl bug. tested with: Tcl8.4.16 + XOTcl1.5.6 Tcl8.5.0 + XOTcl1.5.6
regards Florian
# ************************************************************************ ****** puts "Tcl[set ::tcl_patchLevel]" puts "XOTcl [package require XOTcl]" ;# XOTcl 1.5.6, 1.5.5 namespace import xotcl::* # ######################################################################## ###### Class X -slots { Attribute create q } # ************************************************************************ ****** X instproc init {args} { next my trace add variable q {write unset} [list [self] trc] } # ************************************************************************ ****** X instproc trc {args} { puts "[self] [info level 0]" } # ************************************************************************ ****** X instproc test1 {} { puts "[info level 0]" puts " trace info = [my trace info variable q]" my copy ::b puts " trace info = [my trace info variable q]" puts "'copy' kills the trace!" } # ************************************************************************ ****** # ######################################################################## ###### X create ::a -q hallo ::a test1
Dear Florian,
tcl var-traces and copy/move operations is a hairy issue. You are right, the the current behavior on the issue is a bug. I can't currently look into the details (i am on vacation in a small place in the alps until Jan 6), but my guess is that the behavior was introduced by the changes due to VarReform.
Use the following fix in the meantime, until i have more time to look into the details (insert this code before the first copy).
best regards -gustaf neumann
Class PreserveVarTraces PreserveVarTraces instproc copy {obj dest} { set traces "" foreach v [$obj info vars] { set t [$obj trace info variable $v] if {$t ne ""} { foreach ops $t { foreach {op cmd} $ops break append traces [list $obj trace add variable $v $op $cmd] "\n" } } } set r [next] eval $traces return $r } ::xotcl::Object::CopyHandler instmixin add PreserveVarTraces