Skip to content
Tcl Source Code History Of Ticket 871387ffffffffffffffffffffffffffffffffff
Login

History Of Ticket 871387ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 871387ffffffffffffffffffffffffffffffffff

  1. Ticket change [25f2c8680a] (rid 88251) by mic42 on 2004-01-06 02:22:24:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The dict exists subcommand shows a behaviour that is
      not clearly documented but unexpected, so either this
      is a documentation bug or a misfeature/real bug.
      
      I tried to update msgcat.tcl to dicts and stumbled
      accross the following:
      
      set Msgs [dict create]
      # create a subdict for a locale
      dict set Msgs de [dict create]
      # create a subdict for a namespace
      dict set Msgs de "" [dict create]
      # create an entry there
      dict set Msgs de "" hello Hallo
      
      # check if a translation exists
      dict exists $Msgs fr "" hello
      
      This throws an error if the subdict fr and fr "" does
      not exist. I would expect it to simply return 0. 
      
      It would be better if it simply returned 0, as there is
      no good (and fast) workaround.
      
      The only alternatives are:
      
      set ok 0
      set path ""
      foreach key {fr "" hello} {
         lappend path $key 
         if {[dict exists $Msgs {expand}$path]} {
              set ok 1
         } else {
              break
         }
      }
      
      or:
      
      if {[catch {dict exists $Msgs fr "" hello} val]} { ... }
      
      As i think a check for element existance is a common
      operation it should not need such complex workarounds
      to be useful for nested dicts.
      
      The current behaviour would be more appropriate for
      something like a dict exists -strict command variant.
      
      Michael
      
      
      
      
      
      
      
    4. foundin initialized to: "obsolete: 8.5a0"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "mic42"
    9. subsystem initialized to: "15. Dict Object"
    10. title initialized to: "dict exists throws unexpected error"
    11. type initialized to: "Bug"
  2. Ticket change [f0a6aa9fba] (rid 109230) by dkf on 2004-01-15 04:13:52:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Hmm.  Is it a bug or a misfeature?  I've a test (dict-9.5)
      checking for exactly this behaviour...
      
      Review of documentation indicates bug.  :^/
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [671afd5f4d] (rid 102846) by dkf on 2004-01-15 05:10:42:

    1. closedate changed to: "2004-01-14T22:10:42"
    2. closer changed to: "dkf"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      I attach the patch I used to fix the fault.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dkf"
  4. Ticket change [cd4caae548] (rid 95864) by dkf on 2004-01-15 05:10:43:

    1. icomment:
      
      
      File Added - 73469: dict.patch
      
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  5. Add attachment "dict.patch" [5a94ba4f1c] (rid 118167) by dkf on 2004-01-15 05:10:43.