Posted to tcl by mjanssen at Tue Feb 10 00:10:48 GMT 2009view raw

  1. # missing items
  2. # 1) ability to yield an error (possibly with -level to create nice error messages in the same manner as return)
  3. # 2) ability to call the coro with arbitrary # args (yield will always return a list)
  4. # 3) maybe, abillity to do info level (not sure if this is really doable/useful
  5.  
  6.  
  7. proc _object {args} {
  8. set next [lindex $args 0]
  9. while {$next ne "destroy"} {
  10. # actual dispatch loop will be here
  11. switch [lindex $next 0] {
  12. parents* {
  13. set res ""
  14. }
  15. clone {
  16. set res $a
  17. }
  18. "" {
  19. set a 4
  20. set res ok
  21. }
  22. }
  23. set next [yield $res]
  24. }
  25. }
  26.  
  27. coroutine Object _object
  28.  
  29. Object parents*
  30. Object clone
  31. Object destroy
  32. Object sadas