Tcl's [trace add execution Class leave] does not interact with the constructor/instance creation.
The result parameter passed to the callback is empty, furthermore, [itcl::find objects -class Class] does not show the newly created object (it appears the callback is being called too early?).
This worked properly in Tcl 8.4, Itcl 3.2, is failing in Tcl 8.6.6, Itcl 4.1.1
Expected output is:
Result is: class0
Result of itcl::find: class0
New object is class0
itcl::find is: class0
But in 8.6.6/4.1.1, the 'class0' is not present on the two lines beginning with Result.
code is:
#--Tcl-- the next line restarts using wish \
exec tclsh "$0" "$@"
package require Itcl
itcl::class Class {
}
proc leave_callback {cmdstring code result op} {
puts "Result is: $result"
puts "Result of itcl::find: [itcl::find objects -class Class]"
}
trace add execution Class leave leave_callback
set newobj [Class #auto]
puts "New object is $newobj\nitcl::find is: [itcl::find objects -class Class]"
exit
~~~~
This change is due to a re-implementation in terms of [tailcall].
Here's a Tcl-only demonstration:
% proc cb args {puts TRACE:$args}
% proc demo {} {
tailcall string cat x
}
% trace add execution demo leave cb
% demo
TRACE:demo 0 {} leave
x
If execution traces and [tailcall] are not supposed
to interact this way, it's a matter to get resolved
in Tcl itself.
This is probably related:
http://core.tcl.tk/tcl/tktview?name=3610400fff