Version 0 of shorthand dict set

Updated 2014-05-20 02:19:59 by samoc

Syntax sugar for "dict set" and "dict get".

rename set _set

proc set {args} {
    if {[llength $args] <= 2} {
        uplevel [list _set {*}$args]
    } else {
        uplevel [list dict set {*}$args]
    }
}

proc get {dict args} {
    uplevel dict get [list $dict] $args
}

This over-loads plain-old "set" to allow "set dict_var key... $value" as shorthand for "dict set dict_var key... $value". Normal "set" behaviour is retained.

"get" is there too for symmetry.

Some may see this as heresy, but I think it makes dictionary-heavy scripts more readable :)