Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Here's a hacky version of one of their examples, with "reactive Tcl", which is essentially powered by the trace command.

    proc timeB {varname seconds} {
        upvar $varname x
        set x [clock seconds]
        after [::tcl::mathop::* $seconds 1000] [list timeB $varname $seconds]
    }

    proc onChange {varname empty op} {
        upvar $varname x
        puts $x
    }

    timeB foobar 1
    trace add variable foobar write onChange

    vwait forever
Tcl - doing cool things before they were cool since 1990.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: