Skip to content
Tcl Source Code History Of Ticket 219378
Login

History Of Ticket 219378

Artifacts Associated With Ticket 219378

  1. Ticket change [2b003bcc54] (rid 118663) by nobody on 2000-10-26 05:11:51:

    1. assignee initialized to: "nobody"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      OriginalBugID: 6023 RFE
      Version: 8.3.1
      SubmitDate: '2000-07-19'
      LastModified: '2000-10-25'
      Severity: LOW
      Status: UnAssn
      Submitter: techsupp
      OS: Macintosh
      OSVersion: linuxppc  linux-kernel 2.2.14pre9 (will be MacOS-X :-)
      Machine: Macintosh Blue G3
      FixedDate: '2000-10-25'
      ClosedDate: '2000-10-25'
      
      
      Name:
      Maurice Diamantini
      
      Extensions:
      nothing
      
      CustomShell:
      nothing
      
      DesiredBehavior:
      "string range" should accept a list as indices arguments
      so the syntaxe could becomme:
      
        string range string first last
      
      instead of simply:
      
        string range string pairList
      
      ------------------------------------------------------------
      Exemple:
      
        set txt "aaa123bbb679ccc"
        set pat {(\d+)\D*(\d+)}
        regexp  -indices $pat $txt  all  var1_indexes var2_indexes
        # ... drop things made with indices ...
        # then get the chunks of txt :
        set var1 [string range $txt  [lindex $var1_indexes 0]  [lindex $var1_indexes 1]]
      
        set var2 [string range $txt  [lindex $var2_indexes 0]  [lindex $var2_indexes 1]]
      
      As list data type a powerfull feature of the Tcl language, 
      I'd prefer to be able to write :
      
        set var1 [string range $txt $var1_indexes]
        set var2 [string range $txt $var2_indexes]
      
      Or even (if needed)
        set varChunk [string range $txt "$var1_indexes $var2_indexes" ]
      
      ------------------------------------------------------------  
      Obiously one can do a proc for it :
      
        ## String:range -- return sub-string based on pair list of indices
        # 
        # Do the same as "string range" tcl command, but take a list of 
        # two indices instead of two indices as parameters
        # (then extended to take an arbitrary pair list)
        # 
        # example:
        #     set txt "aaa123bbb679ccc"
        #     set pat {(\d+)\D*(\d+)}
        #     regexp  -indices $pat $txt  all  var1_indexes var2_indexes
        #     set var1 [String:range $txt $var1_indexes]
        #     set var2 [String:range $txt $var2_indexes]
        #     set varChunk [String:range $txt "$var1_indexes $var2_indexes" ]
        # 
        proc String:range {str indices} {
            set res ""
            foreach {first last} $indices {
                append res  [string range $str $first $last]
            }
            set res
        }
      
      
      
      
      
    4. foundin initialized to: "obsolete: 8.3.1"
    5. priority initialized to: "5 Medium"
    6. resolution initialized to: "None"
    7. status initialized to: "Open"
    8. submitter initialized to: "nobody"
    9. subsystem initialized to: "69. Other"
    10. title initialized to: ""string range" enhancement request"
    11. type initialized to: "RFE"
  2. Ticket change [b4f3b0a413] (rid 125145) by dkf on 2000-11-15 21:49:56:

    1. foundin changed to: "obsolete: 8.4a3"
    2. icomment:
      I'm reluctant to add this sort of thing just here because it is patching a single spot instead of addressing the wider problem of splitting arguments.  A general solution so that expansion of lists into several command arguments would be a much more effective use of time...
      
      
    3. login: "dkf"
    4. mimetype: "text/plain"
    5. subsystem changed to: "81. Bundled Packages"
    6. username: "dkf"
  3. Ticket change [1167b2c683] (rid 95138) by dkf on 2000-12-03 00:59:54:

    1. priority changed to: "1 Zero"
  4. Ticket change [b52c11614b] (rid 125194) by welch on 2000-12-06 14:27:31:

    1. icomment:
      The "eval" command provides a general way to split arguments.
      
      eval [list string range $string] $list_of_two_indices
      or
      eval {string range $string} $list_of_two_indices
      
      I'm inclined to agree with the original request, however, because the the 
      use of eval may add more overhead than you want with large strings.
      It'd be worth measuring the eval approach to see if it's worth a special case.
      
      
    2. login: "welch"
    3. mimetype: "text/plain"
    4. username: "welch"
  5. Ticket change [e4a4a016df] (rid 87986) by dkf on 2000-12-06 17:36:06:

    1. icomment:
      OK, I think I perhaps ought to explain myself.
      
      Firstly, it is trivially easy to work around this using [foreach], though this is a messy solution, admittedly.
      
      Secondly, the optimal current work-around may well be this:
         eval [linsert $list_of_two_indices 0   string range $string]
      (It is optimal since it guarantees that there is no real double evaluation of any values, even though it lacks a lot on the "optimality of representation" front too.)
      
      Thirdly, a full solution ought to address the fact that there are many places in Tcl where this sort of conversion of lists to multiple arguments would be useful, and that a more general solution (a la the {expand}$list discussion of a few months back) would be a far more efficient use of people's time than a horde of special fixes scattered throughout Tcl, Tk and all the various extensions.  If nothing else, the maintenance overhead is much lower.  (Not that I'm advocating a particular syntactic construct here - just the general concept.)  Perhaps I ought to go back over that discussion and see if a suitable TIP can be culled from it...?  Only problem with doing this is that it results in a shed-load of work falling on me from a great height...  :^)
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  6. Ticket change [787d95885c] (rid 89969) by dkf on 2001-02-07 23:07:05:

    1. subsystem changed to: "18. Commands M-Z"
  7. Ticket change [f0368cc15e] (rid 109148) by dkf on 2001-02-15 23:30:02:

    1. assignee changed to: "dkf"
  8. Ticket change [ed816e419d] (rid 103896) by dkf on 2001-02-26 18:48:47:

    1. title changed to: ""string range" enhancement request"
  9. Ticket change [59448dd6c4] (rid 117950) by dgp on 2001-04-04 04:57:34:

    1. subsystem changed to: "18. Commands M-Z"
    2. title changed to: ""string range" enhancement request"
  10. Ticket change [fa93852240] (rid 91897) by dkf on 2003-02-25 16:30:44:

    1. title changed to: "[string range] enhancement request"
  11. Ticket change [082c8aa8eb] (rid 89515) by dkf on 2003-03-10 05:30:01:

    1. title changed to: "[string range] to take index list"
  12. Ticket change [d66330a3ae] (rid 123795) by dkf on 2009-07-14 19:54:51:

    1. icomment:
      With Tcl 8.5, it is possible to do:
        string range $string {*}$indexPair
      
      The multi-pair case... I think that's uncommon enough that we can simply not handle it.
      
      
    2. login: "dkf"
    3. mimetype: "text/plain"
    4. username: "dkf"
  13. Ticket change [5d1e63762f] (rid 115406) by dkf on 2009-07-14 19:54:52:

    1. closedate changed to: "2009-07-14T12:54:52"
    2. closer changed to: "dkf"
    3. icomment:
      
      
      allow_comments - 1
      
      
      
    4. login: "dkf"
    5. mimetype: "text/plain"
    6. resolution changed to: "Out of Date"
    7. status changed to: "Closed"
    8. username: "dkf"