Skip to content
Tcl Source Code History Of Ticket 197e2bf85c
Login

History Of Ticket 197e2bf85c

Artifacts Associated With Ticket 197e2bf85c

  1. Ticket change [8a03545e3a] (rid 132851) by anonymous on 2013-07-14 07:53:48:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      This is probably an error in the documentation, not in the command.
      
      "info frame" returns a dict with a 'level' entry, defined as
      
      > level
      >    This entry is present only if the queried frame has a corresponding frame returned by info level.
      > It provides the index of this frame, relative to the current level (0 and negative numbers).
      
      That isn't what actually happens. What happens appears to be:
      1. The level is indeed a relative level, but uses the convention of 'uplevel', not 'info level', namely 0 or a positive number.
      2. "corresponding" is rather vague, but it seems more accurate to say that 'level' is the caller's level rather than the level of the frame itself.
      3. As far as I can tell, 'level' is always present.
      
      Taken together, this is sufficiently different that the actual values are hard to interpret. Example:
      
      set x 10
      
      proc tst {x} {
          incr x
          eval eval tst2 $x
      }
      
      proc tst2 {x} {
          incr x
          set depth [info level]
          for {set i $depth} {$i > 0} {incr i -1} {
              set rel [expr $i - $depth]
              puts "level $i ($rel) = [info level $i]"
          }
          set depth [info frame]
          for {set i $depth} {$i > 0} {incr i -1} {
              set frame [info frame $i]
              set level [dict get $frame level]
              set rel [expr $i - $depth]
              puts "frame $i ($rel) -> level $level ([dict get $frame cmd])"
          }
      }
      
      When called as "tst $x" this prints
      
      level 2 (0) = tst2 11
      level 1 (-1) = tst 10
      frame 5 (0) -> level 0 (info frame $i)
      frame 4 (-1) -> level 1 (tst2 11)
      frame 3 (-2) -> level 1 (eval tst2 11)
      frame 2 (-3) -> level 1 (eval eval tst2 $x)
      frame 1 (-4) -> level 2 (tst $x)
      
      From the documentation, I expected
      frame 5 -> (no level)
      frame 4 -> level 0
      frame 3 -> (no level)
      frame 2 -> (no level)
      frame 1 -> level -1
      
      However, if you try to use 'uplevel' to determine what the values of $i and $x are in the commands, then it turns out the returned levels are exactly right: add
              puts "[uplevel $level subst [list [dict get $frame cmd]]]"
      to the above loop.
      
      -Marcel van der Goot
      
    5. foundin initialized to: "8.6.0"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "f911612b13fc724ee2ff97acb8261b48c1b25f3c"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "- New Builtin Commands"
    15. title initialized to: "info frame 'level' does not match documentation"
    16. type initialized to: "Bug"