Posted to tcl by aspect at Tue Apr 05 06:50:43 GMT 2016view raw

  1. set it [interp create]
  2. $it eval {
  3. namespace eval ToUpper {
  4. proc initialize {x mode} { info procs }
  5. proc finalize {x} { }
  6. proc write {x data} { string toupper $data }
  7. proc flush {x} { }
  8. namespace export *
  9. namespace ensemble create
  10. }
  11. chan push stdout ToUpper
  12. puts "hello from interp" ;# HELLO FROM INTERP - as expected
  13. }
  14.  
  15. puts "hello from main" ;# HELLO FROM MAIN - hmm .. insufficiently documented?
  16.  
  17. interp cancel $it
  18.  
  19. puts "hello at end" ;# eval canceled while executing "ToUpper write rt0 {hello at end\n}"
  20.  
  21. ;# missing [chan pop] - or other bugs in slave interps' transchans - can affect master interp :-(
  22.