Posted to tcl by dgp at Thu Jun 13 15:02:31 GMT 2019view raw

  1. $ cat evtest.tcl
  2. namespace eval provide {
  3. proc irk args {puts BROKEN!}
  4. proc every {ms script} {
  5. puts $script
  6. try $script
  7. set callerNs [uplevel 1 {::namespace current}]
  8. after $ms [list after idle [list namespace inscope $callerNs [info level 0]]]
  9. }
  10. namespace export every
  11. }
  12. namespace eval consume {
  13. namespace import ::provide::every
  14. rename every irk
  15. irk 1000 {puts TICK}
  16. }
  17. vwait forever
  18.  
  19. $ tclsh evtest.tcl
  20. puts TICK
  21. TICK
  22. puts TICK
  23. TICK
  24. puts TICK
  25. TICK
  26. ...
  27.