If a nested method of Incr Tcl
class is called without using $this
it's failed in coroutine with the error
cannot yield: C stack busy
But calling the same method through $this
works. Why? What's the difference? Because it works both ways
without coroutine.
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