1

Incr Tcl如果在不使用的情况下调用类的嵌套方法,则$this在协程中失败并出现错误

cannot yield: C stack busy

$this但是通过工程调用相同的方法。为什么?有什么不同?因为它在没有协程的情况下双向工作。

package require Itcl

itcl::class A {
  method internal {} {
    puts "internal"
    if {[info coroutine] !=""} yield
  }
  method external {f} {
    puts "external $f"
    switch $f {
     use_this     { $this internal   ;# this works with coroutine }
     without_this { internal         ;# but this does not         }
    }
  }
  method outer {f args} {
    puts "outer $f $args"
    switch $f {
      coroutine { coroutine co $this {*}$args }
      direct    { {*}$args                    }
    }
    puts "-----"
  }
}

A a

a outer direct internal
a outer direct external use_this
a outer direct external without_this

a outer coroutine internal
a outer coroutine external use_this
a outer coroutine external without_this  ;# <-- ERROR: cannot yield: C stack busy
4

1 回答 1

0

这似乎是一个错误,所以你应该在这里放一张票: https ://core.tcl-lang.org/itcl/tktnew

于 2021-03-25T15:09:22.013 回答