Posted to tcl by pooryorick at Sun Nov 08 05:01:54 GMT 2015view raw

  1. #grap scriptSplit from http://wiki.tcl.tk/21701
  2. rename proc ::tcl::proc
  3.  
  4. ::tcl::proc proc {name args body} {
  5. ::uplevel [::list ::tcl::proc $name $args [::list apply [::list args [
  6. ::string map [::list {${body}} [::list $body]] {
  7. ::foreach command [::scriptSplit ${body}] {
  8. ::if {[::catch [::list ::uplevel 1 $command] cres copts]} {
  9. ::tailcall ::errorhandler $cres $copts
  10. }
  11. }
  12. }
  13. ]] [uplevel namespace current]]]
  14. }
  15.