Keylset error in Tcl 8.4 and 8.5?

Consider the following simple exercise:

package require Tclx
keylset myArray "v1.5" "ready"
puts $myArray

Expected Result:

{v1.5 ready}

Actual conclusion:

{v1 {{5 ready}}}

My questions

  • This seems to be a bug in keylset, I confirmed this behavior on both 8.4 and 8.5
  • How do I get around this? I tried several ways to quote the key to no avail.
+2
source share
2 answers

This is not a mistake, this is a feature. :) Dot is a hierarchical key separator in the list of keys.

See an example for an explanation:

keylset myArray {v1.5} "ready" {v1.6} "empty"

puts $myArray                ;# ==> {v1 {{5 ready} {6 empty}}}
puts [keylget myArray v1]    ;# ==> {5 ready} {6 empty}
puts [keylget myArray v1.5]  ;# ==> ready
puts [keylget myArray v1.6]  ;# ==> empty
+4
source

keylset is a Tclx command. I would recommend you take a look at the dict command from Tcl 8.5

+1
source

All Articles