comp.lang.tcl
[Top] [All Lists]

Re: merging variables and arrays ...

Subject: Re: merging variables and arrays ...
From: Alexandre Ferrieux
Date: Fri, 30 May 2008 05:01:10 -0700 PDT
Newsgroups: comp.lang.tcl

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

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy