return $num
}
+ proc decomma {str} {
+ switch [string index $str end] {
+ , { string range $str 0 end-1 }
+ default { return $str }
+ }
+ }
+
proc list {args} {
variable indent
variable nl
append out $nl$indent
append out [ deparse $el ],
}
+ set out [ decomma $out ]
outdent_one
append out $nl$indent\]
return $out
dict for {k v} $args {
append out $nl$indent[ str $k ]:\ [ deparse $v ],
}
+ set out [ decomma $out ]
outdent_one
append out $nl$indent\}
}
]
}
+namespace eval ten::connection {
+
+ proc receive_data_for {name} {
+
+
+ proc conn_setup {name input output initial_handlers} {
+ variable "${name}_input" $input
+ variable "${name}_input_closed" ""
+ variable "${name}_output" $output
+ variable "${name}_handlers"
+ array set "${name}_handlers" $initial_handlers
+ fileevent $input readable [list receive_data_for $name]
+ puts $output Shere
+ }
+
+ proc run_until_close {name} {
+ vwait "${name}_input_closed"
+ set close_value "\$${name}_input_closed"
+ teardown $name
+ return $close_value
+ }
+
+ proc teardown {name} {
+ close [ expr "\$${name}_output" ]
+ unset "${name}_input"
+ unset "${name}_input_closed"
+ unset "${name}_output"
+ unset "${name}_handlers"
+ }
+
namespace import ten::json::*
puts [ deparse_json $ex_json 2 ]