Updated 2014-05-17 22:44:11 by pooryorick

George Peter Staplin 2006-07-28: TFP is my new programming system. I've created what I call box programming. Basically each box is an asynchronous process that communicates with other boxes via ports. In TFP each box forks from the router, and does a unique job. TFP is a domain-specific language built on top of Tcl.

lexfiend 2006-08-12: Which begs the question: Is TFP short for Tcl Flow-based Programming?

George Peter Staplin 2006-08-12: Yes. I wrote a paper for the conference about this, and I give credit to Flow-Based Programming for inspiring what I created. It will appear after the conference. What's unique is my box abstraction and the domain-specific language I've created for it in Tcl. I also used processes rather than threads, unlike some other modern implementations of FBP. I've also changed the names of some components, because I think "router" is a better description than "scheduler" for my implementation.

The first application built with TFP is called TFP Shell. It's an interactive shell with image support.

For instance here is an image box:
box image {
    load [file join $::shellbinpath pngext2.so] Pngext2
} takes filename {
    if {[catch {out 1 [pngext2:decode file $filename]} result]} {
                out 0 error
                out 1 $result
         out 0 image
} out 2

To use that box I might have something like:
box interactor {
    # This is the init path.  It can contain procs and other startup code.
    package require Tk
    load [file join $::shellbinpath megaimagetk.so]
    pack [button .b -text {Load image} -command {
        out 0 /path/to/somefile.png}]
    pack [label .img]
} takes {type data} {
    switch -- $type {
        error {
            tk_messageBox -icon error -message $data

        image {
            set img [image create photo]
            megaimage.to.photo $data $img
            .img configure -image $img
} out 1

Then I connect the boxes like so:
connect interactor 0 image 0
connect image 0 interactor 0
connect image 1 interactor 1
vwait forever