Posted to tcl by aspect at Fri Mar 01 22:49:16 GMT 2024view raw

  1. #!/usr/bin/env tclsh
  2. #
  3. #
  4.  
  5. set interp [interp create]
  6.  
  7. $interp eval {
  8. proc Try {script} {
  9. list [catch {uplevel #0 $script} e o] $e $o
  10. }
  11. }
  12.  
  13. proc Call {interp script} {
  14. lassign [$interp eval [list Try $script]] rc res opts
  15. return -code $rc -options $opts $res
  16. }
  17.  
  18. proc putl args {
  19. puts $args
  20. }
  21.  
  22. interp bgerror {} {putl bgerror}
  23.  
  24. after 0 {Call $interp {expr 1/0}}
  25.  
  26. after 100 {incr forever}
  27. vwait forever
  28. puts done
  29.