Artifacts Associated With Ticket 689652ffffffffff
Ticket change [42dd07842d] (rid 116446) by vincentdarley on 2003-02-19 23:06:10:
- assignee initialized to: "dkf"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Recent versions of Tcl introduced the '-sorted', and '-all' flags to lsearch (with associated flags '- ascii', '-dictionary', 'integer', etc). However, many combinations are disallowed, and some of the implementation could be made more efficient. For example 'lsearch -sorted -all' doesn't do a binary search, claiming (in the code) "note that there is no point in being smart when -all was specified; in that case, we have to look at all items anyway". But that isn't true, one could do a forward and a backward binary search and then return the remaining range (or do a forward binary search and then a forward negated binary search from that point). Another problem is that one can't use any form of pattern with '-sorted', which would be very useful. For example these useful examples are illegal: lsearch -sorted -glob -- "aaaa aabb aabc aacc abcc" "aab*" would (if the list was much longer, like a dictionary) return 1, and: lsearch -sorted -glob -all -- "aaaa aabb aabc aacc abcc" "aab*" would return "1 2" (and with '-inline' this would be a nice way of efficiently returning just the relevant 'lrange'). Finally, I point out that several examples at the bottom of the lsearch man page use a '-data' option which is not in Tcl at all!
- foundin initialized to: "None"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "vincentdarley"
- subsystem initialized to: "17. Commands I-L"
- title initialized to: "lsearch fuller functionality (and small doc bug)"
- type initialized to: "RFE"
Ticket change [b9e3c5e126] (rid 129224) by vincentdarley on 2003-02-20 16:01:01:
- icomment:
Logged In: YES user_id=32170 One more comment, 'lsearch' always searches from the front of the list. Why not '-last' (or -reverse) flag?
- login: "vincentdarley"
- mimetype: "text/plain"
- username: "vincentdarley"
- icomment:
Ticket change [4314b1935f] (rid 116484) by dkf on 2003-02-20 22:46:45:
- icomment:
Logged In: YES user_id=79902 Jeff got rid of that doc bug last August. :^)
- login: "dkf"
- mimetype: "text/plain"
- title changed to: "lsearch fuller functionality"
- username: "dkf"
- icomment:
Ticket change [658fb774f4] (rid 102572) by vincentdarley on 2003-02-27 19:47:28:
- icomment:
Logged In: YES user_id=32170 Comments from tcl-core: On Thu, 27 Feb 2003, Michael Schlenker wrote: > Looks also reasonable, but I note, that your "illegal" - sorted + pattern > examples do work... Indeed, now I see they do, but they *ignore* the '- sorted' flag. This contradicts what is in the man page, where '-sorted' is explicitly mutually exclusive with -glob and -regexp. I think an error should be thrown for illegal flag combinations. The man page really ought to specify what happens in this case, and also in the case where the list isn't sorted but '-sorted' is given (even if only to say the behaviour is undefined). Currently using '-all' tends to hide all these problems because the implementation with -all is brute force (I doesn't use the fact that -sorted could still provide a benefit).
- login: "vincentdarley"
- mimetype: "text/plain"
- username: "vincentdarley"
- icomment:
Ticket change [376067c5be] (rid 107264) by dkf on 2003-02-27 23:31:53:
- resolution changed to: "Rejected"
- status changed to: "Closed"
Ticket change [ffa5612401] (rid 108783) by dkf on 2003-02-27 23:31:54:
- closedate changed to: "2003-02-27T16:31:54"
- closer changed to: "dkf"
- icomment:
Logged In: YES user_id=79902 You *can't* mix glob matching and specialised sorting handling. This is because you can only tell whether a glob pattern matches or not, and not whether there cannot be a match before the given entry because of that. Consider the glob pattern *[abyz]?[cdx]* - how could you even begin to combine that with an ordering criterion?! Similar problems with -regexp, of course. With -all, you have a similar thing in that it is really designed for use with -glob and -regexp. Is the case of an exact search of sorted non-unique list all that common? Maybe could do with a new -prefix option; prefix matching *would* be compatible with -sorted. Backwards searching would be another nice feature. Please open a new FRQ or submit a TIP if you want to take them further.
- login: "dkf"
- mimetype: "text/plain"
- username: "dkf"
Ticket change [129e56fbdb] (rid 124062) by dkf on 2007-01-14 22:36:21:
- is_private changed to: "1"