Version 0 of procstep

Updated 2015-11-08 13:39:36 by pooryorick

PYK 2015-11-08: procstep is s drop-in replacement for proc that evaluates one command of a procedure body at at time, and a hook to inspect and manipulate the command before it is evaluated, and another to react to return conditions of the evaluation.

rename proc ::tcl::proc

::tcl::proc proc {name args body} {
   ::uplevel [::list ::tcl::proc $name $args [::list apply [::list args [
      ::string map [::list {${body}} [::list $body]] {
         ::foreach command [::scriptSplit ${body}] {
            ::if {[::catch [::list ::uplevel 1 [
               ::cmdhandler $command]] cres copts]} {
               ::tailcall ::errorhandler $cres $copts
            }
         }
      }
   ]] [uplevel {namespace current}]]]
}

::tcl::proc cmdhandler command {
   ::puts [::list {now executing} $command]
   return $command
}

::tcl::proc errorhandler {cres copts}  {
   #puts $args
   ::puts [list {got an error} $cres]
   #puts [uplevel info locals]
}