Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-08-01
09:21 • Ticket [967565ffff] info level reports current interp's CallFrames only</i... artifact: d7256953ad user: mistachkin
09:21 • Ticket [967565ffff]: 1 change artifact: 98fc72b859 user: mistachkin
2004-06-09
04:22 • Ticket [967565ffff]: 4 changes artifact: 375cb490d9 user: dkf
2004-06-08
05:26 • Ticket [967565ffff]: 4 changes artifact: 706a6ecbab user: mistachkin
04:56 • Ticket [967565ffff]: 4 changes artifact: 9877f1f4ba user: dgp
04:47 • Ticket [967565ffff]: 5 changes artifact: 6fb48d1e2c user: dgp
04:31 • Ticket [967565ffff]: 1 change artifact: 8f958d5333 user: mistachkin
2004-06-07
05:37 • Ticket [967565ffff]: 4 changes artifact: 6346d17951 user: mistachkin
05:37 • Add attachment call-stack.tcl to ticket [967565ffff] artifact: 3dbf1f1d0e user: mistachkin
2004-06-06
19:17 • Ticket [967565ffff] interp alias problem... status still Open with 4 other... artifact: 100fafec97 user: mistachkin
19:17 • Add attachment test.tcl to ticket [967565ffff] artifact: b41e613949 user: mistachkin
12:15 • New ticket [967565ffff] interp alias problem.... artifact: 06462983f8 user: mistachkin

[info level] reports current interp's CallFrames only

Open967565ffffffffffffffffffffffffffffffffffCreated 22 years agoUpdated 21 years ago
Descriptionplain2004-06-06 12:15:51
Unless I have missed something in the docs (which is 
entirely possible at this hour), this behaviour is either a 
bug or a documentation oversight.  

Is there some bad interaction here between slave 
interps and [interp alias]?  Perhaps the combination of 
slave interps and namespaces triggers this problem?  

If this is NOT a bug, it is still downright confusing.  
Having [info level] "skip over" a caller in the stack is not 
ideal.

----

namespace eval ::test {
  proc procA { interp } {
    if {$interp} then {
      global i
      interp alias $i ::test::A::procB {} ::test::procB
      interp eval $i [list namespace eval ::test::A procC]
    } else {
      interp alias {} ::test::A::procB {} ::test::procB
      namespace eval ::test::A procC
    }
  }

  proc procB {} {
    set current [lindex [info level [info level]] 0]

    # should print "::test::procB"
    puts stdout "current ([info level]) == $current"

    if {$current == "::test::procB"} then {
      puts stdout "SUCCESS, current proc match."
    } else {
      puts stdout "FAILURE, current proc mismatch."
    }

    set parent [lindex [info level [expr {[info level] - 1}]] 
0]

    # should print "::test::A::procC" or "procC"
    puts stdout "parent ([info level] - 1) == $parent"

    if {[string match "*procC" $parent]} then {
      puts stdout "SUCCESS, parent proc match."
    } else {
      puts stdout "FAILURE, parent proc mismatch."
    }
  }
}


foreach this_interp [list 0 1] {
  puts stdout "Running test with use_new_interp set to 
$this_interp."

  if {$this_interp} then {
    set i [interp create]
    
    interp eval $i {
      namespace eval ::test::A {
        proc procC {} {
          procB
        }    
      }
    }
  } else {
    namespace eval ::test::A {
      proc procC {} {
        procB
      }    
    }
  }
  
  ::test::procA $this_interp
}
mistachkinplain2004-06-06 19:17:27
File Added - 89675: test.tcl
mistachkinplain2004-06-07 05:37:16
File Added - 89728: call-stack.tcl
mistachkin Ticket [967565ffff]: 1 change [History diff]2004-06-08 04:31:52
dgpplain2004-06-08 04:47:43
Logged In: YES 
user_id=80530


It's probably fair to say this
is underdocumented.

[info level] does not trace back
through the caller sequence,
weaving in and out of interps.
Instead, it reports the stack
of CallFrame's for the current
interp only.

This is intentional, though you
may need to consult with the
original [interp] creators to get
a best explanation of the reasons
why.  If Jacob Levy is available,
he might be able to fill in more
details.
dgpplain2004-06-08 04:56:38
Logged In: YES 
user_id=80530


Note that the "level"s reported
on by [info level] are the same
ones which govern [uplevel] and
[upvar].  That might explain
why only the current interp's
CallFrames are tracked.  You would
not want an [uplevel] to cause 
substitution/evaluation in a different
interp.
mistachkinplain2004-06-08 05:26:52
Logged In: YES 
user_id=113501

Actually, such a feature might be desirable in some 
circumstances (primarily when a safe interp calls a proc in a 
master interp that needs to modify variables in the calling 
child proc via upvar, etc).
dkfplain2004-06-09 04:22:37
Logged In: YES 
user_id=79902

It's possibly the case that we need [interp set], but it is
usually not to big a problem in practice.

Inter-interp [upvar] is deeply evil.  I don't want to be
that scared.
mistachkin Ticket [967565ffff]: 1 change [History diff]2005-08-01 09:21:13
mistachkinplain2005-08-01 09:21:15
Logged In: YES 
user_id=113501


Since this appears to be by design, perhaps we can address
it in the 9.0 timeframe (maybe with an optional arguments
that allow you to "escape" out of the child interp, if the
master allows it):

interp set varName ?value?
info level ?level? ?list_of_interps?

etc
Log in (anonymous is fine) to add a comment.

Attachments: