Updated 2016-07-06 17:32:28 by dbohdan

word.tcl is an implementation of word channels found in ycl.


You can download word.tcl for use outside of ycl (under the namespace ::wordchan rather than [yclprefix]::chan::word) with the following POSIX shell command:

(echo -e "namespace eval ::wordchan {\nnamespace export *\nnamespace ensemble create\n"; curl -s 'https://chiselapp.com/user/pooryorick/repository/ycl/raw/packages/chan/lib/word.tcl?name=024541bdf04b7a9e637add29ac2cd75df2543e74'; echo -e "\n}") > wordchan.tcl

Use example

#!/usr/bin/env tclsh
source wordchan.tcl

proc main {} {
    set ch [chan create {read write} ::wordchan]
    chan configure $ch -buffering none
    chan event $ch readable [list puts --$ch]
    puts -nonewline $ch HELLO
    puts -nonewline $ch WORLD
    puts [read $ch] ;# Prints "HELLO".
    puts [read $ch] ;# Prints "WORLD".