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

History Of Ticket 759545ffffffffffffffffffffffffffffffffff

Artifacts Associated With Ticket 759545ffffffffffffffffffffffffffffffffff

  1. Ticket change [90399480ca] (rid 120415) by kenj on 2003-06-23 23:38:24:

    1. assignee initialized to: "dkf"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      Either the documentation for the lsearch -dictionary 
      option is misleading, or the option isn't implemented 
      properly.
      
      The documentation states:
      
      "-dictionary: The list elements are to be compared using 
      dictionary-style comparisons. This option is only 
      meaningful when used with -exact or -sorted."
      
      Drawing from the behavior of lsort -dictionary, one would 
      assume that the lsearch -dictionary would be case-
      insensitive and handle embedded numbers appropriately. 
      In other words, one might reasonably assume that both 
      of the following lsearch commands would return 1:
      
      % set vals [lsort -dictionary {B4.GIF b13.gif b2.Gif B7.gif 
      b8.gif}]
      b2.Gif B4.GIF B7.gif b8.gif b13.gif
      % lsearch -sorted -dictionary $vals b4.gif
      -1
      % lsearch -exact -dictionary $vals b4.gif
      -1
      
      In fact, they return -1. Thus, in reality the only use 
      currently for lsearch -dictionary is to signal the the list is 
      sorted equivalently to the return value of lsort -
      dictionary. In fact, given such a list, a programmer 
      *must* use lsearch -dictionary; omitting it can fail to 
      match successfully. For example:
      
      % lsearch -sorted -dictionary $vals B4.GIF
      1
      % lsearch -sorted $vals B4.GIF
      -1
      
      Reading the code for lsearch in tclCmdIL.c, I'm not sure 
      what is the intended operation of lsearch -dictionary in 
      cases like this. Even in the case of a linear search (for 
      example, if the user executes lsearch -exact -
      dictionary), the DictionaryCompare() function is used. 
      But this is pointless, as the "secondary comparison" 
      feature of DictionaryCompare() still reports "B4.GIF" as 
      less than "b4.gif" (not equal), the same as a simple 
      string comparison.
      
      So, I don't know what the proper resolution is. I see 2 
      options:
      
      1) Change the documentation to indicate that the only 
      purpose of lsearch -dictionary is to signal a "dictionary-
      sorted" list in conjunction with -sorted; or
      
      2) Change the implementation of lsearch -dictionary to 
      produce the following results from the above examples:
      
      % lsearch -sorted -dictionary $vals b4.gif
      1
      % lsearch -exact -dictionary $vals b4.gif
      1
      
    4. foundin initialized to: "obsolete: 8.4.2"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "kenj"
    9. subsystem initialized to: "17. Commands I-L"
    10. title initialized to: "lsearch -dictionary documentation misleading"
    11. type initialized to: "Bug"
  2. Ticket change [8fea74107b] (rid 120355) by dkf on 2003-06-25 03:47:46:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Where there's no exact match, the meaning of [lsearch
      -sorted -dictionary] is fairly straight-forward (get the
      index of the first/every dictionary-matched value in the
      list).  But what if there is an *exact* match and some other
      dictionary-matched values too?
      
      Once I understand the right semantics, a fix is pretty
      trivial.  (My current thought is that we can't share the
      dictionary comparator between lsort and lsearch.  Drat.)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  3. Ticket change [6b1a004ccc] (rid 128260) by dkf on 2003-06-25 04:10:18:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      A different way to look at it is that -dictionary just
      alters the priority of case-difference relative to
      character-ordering.  It doesn't make 'aBc' equivalent to
      'AbC' under either [lsort] or [lsearch].  I think tclguy
      prefers this explanation; anything else will probably
      require a TIP to allow for the specification of how 'exact'
      we want the dictionary matching to be...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  4. Ticket change [2263a97785] (rid 130740) by kenj on 2003-06-25 04:35:21:

    1. icomment:
      Logged In: YES 
      user_id=260635
      
      I don't object to a strict interpretation as suggested by your 
      second follow-up. But that would imply that we need to 
      change the lsearch man page to reflect that interpretation. If 
      that's the approach to take, I don't see that -dictionary does 
      anything in conjunction with the -exact option, and so we 
      should remove the reference to -exact in the -dictionary 
      description. This implies that the only purpose for -dictionary 
      is to signal that the list is in "dictionary-sorted" order. The 
      revise man page should also explicitly point out that lsearch -
      dictionary doesn't imply case-insensitive or other "dictionary-
      style" matches (for example, "b4.gif" won't match "b04.gif").
      
      
    2. login: "kenj"
    3. mimetype: "text/plain"
    4. username: "kenj"
  5. Ticket change [d8bdde2fc2] (rid 107497) by dkf on 2003-07-04 19:09:54:

    1. icomment:
      Logged In: YES 
      user_id=79902
      
      Perhaps another way to write this is:
        ASCII/UNICODE ordering = ABCabc
        Dictionary ordering = AaBbCc
      However, there's also the matter of numeric handling...
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  6. Ticket change [0494a925c1] (rid 120020) by dkf on 2004-09-02 21:01:13:

    1. closedate changed to: "2004-09-02T14:01:13"
    2. closer changed to: "dkf"
    3. icomment:
      Logged In: YES 
      user_id=79902
      
      Clarified the documentation.
      
      For the record, the difference between -ascii and
      -dictionary is not in when two values are equal, but rather
      in how they differ from each other. Since -exact searching
      just requires a yes/no answer to equality, the differences
      between -ascii and -dictionary vanish.
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"
    8. username: "dkf"