Posted to tcl by colin at Wed Nov 17 01:23:05 GMT 2010view raw

  1. namespace eval tcl::unsupported namespace export yieldm
  2. namespace import tcl::unsupported::yieldm
  3.  
  4. proc reader {} {
  5. while {1} {
  6. ::yieldm
  7. }
  8. }
  9.  
  10. oo::class create ::Lamb {
  11. method reader {} {
  12. while {1} {
  13. ::yieldm
  14. }
  15. }
  16.  
  17. constructor {} {
  18. variable ns [info object namespace [self]]
  19. variable coro ${ns}::coro
  20. ::coroutine $coro [self] reader ;# will crash
  21. #::coroutine $coro reader ;# will not crash
  22. }
  23. }
  24.  
  25. [::Lamb new] destroy
  26. foreach o [info class instances ::Lamb] {
  27. if {[catch {info object namespace $o} ns]} {
  28. error "$o is undead"
  29. }
  30. }