sycl

What sycl
Where http://git.syndicate-lang.org/ehmry/sycl
Description A pair of packages for the Preserves Data Language and the Syndicated Actor Model
Documentation preserves.md
syndicate.md
Updated 2015-02-29
License Unlicense

Code example

package require syndicate
namespace import preserves::*

if {$argc != 1} {
    puts stderr "expected a username as a single argument"
    exit 1
}
set nick [lindex $argv 0]

syndicate::spawn chatActor {
    set route {<route [<tcp "::1" 2048>]>}
    connect $route dest {
        variable room $dest
        global nick     
        assert "<Present \"$nick\">" $room

        during {<Present @other #?>} {
            set other [unpreserve $other]
            puts stdout "«$other joined»"
            onStop [list puts stdout "«$other left»"]
        } $room

      onMessage {<Says @who #? @what #?>} {
          set who [unpreserve $who]
          set what [unpreserve $what]
          puts stdout "$who: $what"
      } $room

      set facet [currentFacet]
      proc ${facet}::readMsg {} {
          global nick
          variable room
          set msg [chan read -nonewline stdin]
          while {$msg != ""} {
              message "<Says \"$nick\" \"$msg\">" $room
              set msg [chan read -nonewline stdin]
          }
          endTurn
      }

      chan configure stdin -blocking 0
      chan event stdin readable ${facet}::readMsg
      
  }
}

vwait forever