Posted to tcl by colin at Wed Aug 04 05:54:28 GMT 2010view pretty
foreach x {get? set? unset? witharray equal apply capture nlappend in ni list diff switch transmute} { namespace ensemble configure dict -map [linsert [namespace ensemble configure dict -map] end $x ::tcl::dict::$x] -unknown {::apply {{dict cmd args} { if {[string first . $cmd] > -1} { if {[string index $cmd end] eq "?"} { ::set opt ? ::set cmd [string trim $cmd ?] } else { ::set opt "" } ::set cmd if {[llength $args]} { # [dict a.b.c] -> [dict get $a b c] return [::list dict set$opt {*}[::split $cmd .]] } else { # [dict a.b.c x] -> [dict set a b c x] ::set cmd [::lassign [::split $cmd .] var] ::upvar 1 $var v return [::list dict get$opt $v {*}$cmd] } } } ::tcl::dict}} } ::unset x }