Version 0 of Funky Tcl extensibility

Updated 2002-01-16 20:42:12

Darren New wrote in the comp.lang.tcl newsgroup on 2002-01-16:

Something someone here said made me think of this. Talk about changing the syntax of a language...

 proc where {what} {
    set caller [info level -1]
    set body [info body $caller]
    set body [split $body \n]
    foreach line $body {
        if {-1 != [string first $what $line]} {
            # Or do more complicated processing
            puts $line
        }
    }
    return -code return
 }

 proc here {} {
    where zip
    zippidy doo dah
    zippidy ahy
    Oh my my what a wonderful day.
    zippy the pinhead says
    drink plenty of fluids
 }

 here

As where returns -code return, anything after it is not seen by the Tcl parser. Instead, where "eats" its caller's body and does with it what it pleases... Amazing food for thought. (RS)


Arts and crafts of Tcl-Tk programming