Version 0 of TFP

Updated 2006-07-28 23:52:10

George Peter Staplin 07.28.2006 - 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.

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
   return
  }
  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
 router
 vwait forever

What category?