Skip to content
Tcl Source Code History Of Ticket 47fd91176dd16609
Login

History Of Ticket 47fd91176dd16609

Artifacts Associated With Ticket 47fd91176dd16609

  1. Ticket change [21564b2970] (rid 236899) by mookie on 2025-01-15 19:37:09:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-plain"
    4. comment initialized to:
      I noticed this within NaviServer, but noticed it's also effecting TCL9, and prior.
      
      I'm not sure if this is by design, limited or programmed to, or that if you shouldn't be able to. 
      However I've started heavily using dictionaries within as a in-house data-store and taken it out of context of the standard dictionary key-value design.  
      
      On count, I am currently creating an dictionary of seven elements. 
      
        % dict set MyDictonary store set block key field 1 "hello"
      store {set {block {key {field {1 hello}}}}}
        % dict set MyDictonary store set block key field 2 "world"
      store {set {block {key {field {1 hello 2 hello}}}}}
      
      However, if I try to append another entry to this long dict, it scrambles itself.
      
        % dict append MyDictonary store set block key field 3 "hello world"
      store {set {block {key {field {1 hello 2 world}}}}setblockkeyfield3hello world}
      
      I have a klunky workaround as of retrieving the result, and then appending the new data which then setting that back to the dictionary but it doesn't feel right. 
      
      Am I suppose to be able to append, is this by design? If so, should it allow you to create a seven element dictionary when you cannot append?
      
      Many Thanks.
      
    5. foundin initialized to: "9.x"
    6. is_private initialized to: "0"
    7. login: "mookie"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "eb7513005aa11dbe2a07d8bff76f8af3c25f379b"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "mookie"
    14. subsystem initialized to: "15. Dict Object"
    15. title initialized to:
      Appending to a seven element dictonary causes issues
      
    16. type initialized to: "Bug"
  2. Ticket change [38a1220335] (rid 236900) by oehhar on 2025-01-15 19:56:33:

    1. icomment:
      Hi Mookie,
      
      thanks for the question.
      
      "dict append" appends all arguments to the text of the value of the given key.
      
      To use it the way intended:
      <verbatim>
      set d [dict create d1 v1]
      dict append d d1 v2 v3
      dict get $d d1 -> v1v2v3
      </verbatim>
      
      So, in your case:
      <verbatim>
      dict append MyDictonary store set block key field 3 "hello world"
      </verbatim>
      is equivalent to
      <verbatim>
      dict append MyDictonary store "setblockkeyfield3hello world"
      </verbatim>
      
      I think, in your example, you may just use "dict set".
      
      <verbatim>
      dict set MyDictonary store set block key field 3 "hello world"
      </verbatim>
      
      If you really want string append, there is no buildin support for nested dictionaries.
      
      So, if you want to append to a string in a nested dictionary, you can only:
      <verbatim>
      dict set MyDictionary store set block key field 3\
              [string cat [dict get $MyDictionary store set block key field 3]\
                  "hello world"]
      </verbatim>
      
      Take care,
      Harald
      
    2. login: "oehhar"
    3. mimetype: "text/x-fossil-wiki"
    4. username: "oehhar"
  3. Ticket change [9e31babf54] (rid 236901) by mookie2 on 2025-01-15 22:26:36:

    1. icomment:
      Many Thanks for your reply Harald, that now makes sense.
      I actually meant, I want to append to an existing key within. I explained it wrongly. But does the same but your answer explains it.
      
      
          dict append MyDictonary store set block key field 2 "NewValue"
      
      which I was assuming would then apply "NewValue" to the field 2 key
      
      Result being: store {set {block {key {field {1 hello 2 world NewValue}}}}}
      
    2. login: "mookie2"
    3. mimetype: "text/plain"
  4. Ticket change [093fb455a7] (rid 236905) by oehhar on 2025-01-16 06:34:29:

    1. closedate changed to: "2460691.77395168"
    2. closer changed to: "oehhar"
    3. icomment:
      Hi Mookie,
      
      great.
      
      Yes, I would also appreciate more commands working on subkeys, e.g. "dict append" and "dict lappend" for subkeys.
      Unfortunately, they don't exist and the current command syntax does not allow to implement this easily.
      
      In my daily work, I enjoy the command "pdict" from here: [https://wiki.tcl-lang.org/page/pdict%3A+Pretty+print+a+dict]
      
      Enjoy,
      Harald
      
    4. login: "oehhar"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Wont Fix"
    7. status changed to: "Closed"
    8. username: "oehhar"