Itcl - the [incr Tcl] extension

View Ticket
Login
Ticket Hash: b8daef797ab1dea2666dd762cb199bfa524b59cb
Title: Itcl3/4 incompatibility: info level doesn't give method name as first element
Status: Open Type: Code_Defect
Severity: Important Priority: Immediate
Subsystem: Resolution: Not_A_Bug
Last Modified: 2019-11-02 16:29:53
Version Found In: trunk #05b48e2011
User Comments:
schmitzu added on 2019-10-29 13:21:34:
The script at the end shows this output when run:
lev -1: my m3 1 2 3
lev -2: my m2 1 2
lev -3: c10 m1 1
This is incompatible with Itcl3 which gives:
lev -1: m3 1 2 3
lev -2: m2 1 2
lev -3: m1 1
(this is IMO the "expected" output which is comtatible with
normal "info level" behaviour concerning procs)

Here's the script:
package require Itcl

proc pstack {} {
   for {set i 1} {$i < [info level]} {incr i} {
      puts "lev -$i: [info level -$i]"
   }
}

itcl::class C1 {
   public method m3 {a b c} {
      pstack
   }
   public method m2 {a b} {
      m3 $a $b 3
   }
   public method m1 {a} {
      m2 $a 2
   }
}

set obj [C1 #auto]
$obj m1 1

dgp added on 2019-10-30 19:31:31:
[info level] is a Tcl command, not an Itcl one. It reveals the active commands
on the evaluation stack. Since Itcl 4 is coded on a TclOO foundation, its
execution happens making use of a different stack of evaluations of TclOO
features.

I'm inclined to call this one either "Not a Bug" or "Won't Fix", unless there's
some really key issue here I'm just not getting.

schmitzu added on 2019-10-31 10:18:27:
OK, I see. This seems to be more complex than I expected
first. This istn't an Itcl4 issue. The underlying TclOO 
layer is the cause for this behaviour and IMHO it has 
to be fixed.
Otherwise "info level" will be useless if you use some
OO extension with this behaviour. What TclOO should do 
at least is to put the "method name" as a sublist 
to the call stack. May be "info level" can do this 
itself like:
lev -1: {my m3} 1 2 3
lev -2: {my m2} 1 2
lev -3: {c10 m1} 1

But nevertheless much better is the Itcl3 solution.

Would it be worth to file a bug to core list, or wherever
this should go?

dgp added on 2019-11-01 17:54:21:
I am leaving this ticket open to explore options further, but it's a deep design issue that cannot be fixed for the 4.2.0 release. After that's out we can come back to it.

dgp added on 2019-11-02 16:29:53:
Just as some more background information, there is an active dispute over
what [info level $n] should return when the call history includes a command
that is implemented by rewriting the command and recursing on evaluation.
This happens in things like ensembles and unknown handling.  See this recent
example.

https://core.tcl-lang.org/tcl/tktview?name=8b9854c3d8