|
|
On May 30, 11:58 am, "Donal K. Fellows" <donal.k.fell...@xxxxxxxxx>
wrote:
>
> The other alternative is to put extra syntax into [dict get], but this
> has other problems (the command currently accepts arbitrarily many
> arguments so as to support nested dictionaries). Easiest is to add
> another subcommand; suggestions on that front are welcome.
What about:
[dict getdef $d $key1 ... $keyN $def]
Also generalized to arrays:
[setdef a($key) $def]
== [expr {[info exists a($key)]?$a($key):$def]}]
(and maybe the latter would deserve an opcode. In my experience it is
ubiquitous *and* needs access by name)
-Alex
|
|