Menu

#283 Itcl object creation interaction with [trace add execution Class leave]

4.0*
open
nobody
None
5
2018-06-01
2018-05-30
No

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:

!/bin/sh

#--Tcl-- the next line restarts using wish \
exec tclsh "$0" "$@"

submitted to itcl

Itcl constructor and [trace] do not behave well

The [trace execution leave] callback is not passed the newly created

Additionally, the object isn't even created (itcl::find object -class Class

doesn't return the newly created object

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

Discussion

  • Don Porter

    Don Porter - 2018-06-01

    ~~~~
    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.

     
  • Don Porter

    Don Porter - 2018-06-01
     

Log in to post a comment.