1

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
GrAnd
  • 10,141
  • 3
  • 31
  • 43
  • I'm guessing that the code that incrTcl uses to make `internal` work normally is not NRE-enabled. – Donal Fellows Mar 19 '21 at 14:45
  • And by “normally” I mean “not via `$this`”. – Donal Fellows Mar 19 '21 at 14:51
  • @DonalFellows The only thing I've noticed that `info level 0` in `internal` method returns `::a internal` if the method was called through `$this`, and `my internal` in case of direct calling. – GrAnd Mar 19 '21 at 15:06
  • The error message means “there's a non-NRE aware call on the stack between the coroutine root and here”, and I'm pretty sure that's not in the TclOO call; that's really supposed to be NRE aware from the word go (they were co-developed). Which points to itcl, and I don't know that so well. I also know it's not a standard procedure (those know NRE) and I think it isn't an in-interp alias either. – Donal Fellows Mar 19 '21 at 15:28
  • You might be able to use `info frame` to debug what's going on. – Donal Fellows Mar 19 '21 at 15:30
  • Hmm... `info frame` looks absolutely identical for both cases. – GrAnd Mar 19 '21 at 18:04

1 Answers1

0

This seems to be a bug, so you should put a ticket here: https://core.tcl-lang.org/itcl/tktnew

schmitzu
  • 41
  • 2