REPL with TclX

风行水上 @ 2014-03-12 17:57:27
标签:

    REPL stands for Read Eval Print Loop, looks like a linux shell environment.

    REPL with Tclx

    With the help of Tclx, REPL can be implemented in one command commandloop:

    # REPL = Read Eval Print Loop
    
    package require Tclx
    
    # commandloop ?-async? ?-interactive on | off | tty? \
    # ?-prompt1 cmd? ?-prompt2 cmd? \
    # ?-endcommand cmd?
    
    proc endcommand {args} {
      puts ""
      puts ""
      puts "See U ..."
    }
    
    proc tcl_prompt1 {args} {
      puts -nonewline "tclx % "
    }
    
    
    set tcl_prompt1 tcl_prompt1
    
    commandloop -endcommand endcommand
    
    
    puts "It's Amazing ..."
    
    标签:

      分享到:
      comments powered by Disqus

      27/30ms