Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: f8eceb5e7bf804f5840e850410603fd24ad2d2c3
Ticket: 2817506fffffffffffffffffffffffffffffffff
list handling routines return the first element of a list in
User & Date: sletts on 2009-07-06 16:04:06
Changes

  1. assignee changed to: "dkf"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    Problem also shows up in 8.6.b, not there in 8.4.4. Tested on Windows, Linux (32 & 64 bit) & Solaris.
    
    Many list handling routines return the first element of a list incorrectly when that element starts with #.
    
    Maybe the behaviour is due to a meaning of the # symbol that I don't know about or maybe it's a bug.
    At any rate it's different in 8.5 & 8.6 from 8.4.
    
    
    The problem can be demonstrated trivially. N.B. list and lrange are not the only routines that show this.
    
    set l00 {#1 #2 #3 #4}
    => #1 #2 #3 #4
    set l01 [list #1 #2 #3 #4]
    => {#1} #2 #3 #4
    
    set l02 [lrange $l00 0 end]
    => {#1} #2 #3 #4
    
    set l10 {1 #2 #3 #4}
    => 1 #2 #3 #4
    set l11 [list 1 #2 #3 #4]
    => 1 #2 #3 #4
    
    set l12 [lrange $l10 0 end]
    => 1 #2 #3 #4
    set l13 [lrange $l11 0 end]
    => 1 #2 #3 #4
    
    set l14 [lrange $l10 1 end]
    => {#2} #3 #4
    set l15 [lrange $l10 1 end]
    => {#2} #3 #4
    
    
    One workaround for these simple examples is to rebuild the list using append.
    
    for {set i 0} {$i < [llength $l02]} {incr i} {
       append l03 " " [lindex $l02 $i]
    }
    puts stdout $l03
    => #1 #2 #3 #4
    
    
    I've now noticed another oddity in this area.
    
    concat $l02 $l02
    => {#1} #2 #3 #4 #1 #2 #3 #4
    but
    concat $l03 $l03
    => #1 #2 #3 #4 {#1} #2 #3 #4
    
    
    
  4. foundin changed to: "obsolete: 8.5.7"
  5. is_private changed to: "0"
  6. priority changed to: "5 Medium"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "sletts"
  10. subsystem changed to: "17. Commands I-L"
  11. title changed to:
    list handling routines return the first element of a list in
    
  12. type changed to: "Bug"