Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 432cd065c73299cc7cc7cc58d21afb0ed1830c54
Ticket: 3408408fffffffffffffffffffffffffffffffff
Erratic sharing/duplication of values in [expr]
User & Date: ferrieux on 2011-09-13 06:22:11
Changes

  1. assignee changed to: "dgp"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    To save memory by sharing oft-used values, a natural technique would be
    
     lappend storage [expr {$computed_bit?1:0}]
    
    Unfortunately, the 1 and 0 values coming out of the [expr] are *not* extra references to the hugely shared literals, but fresh copies.
    A mysterious workaround guessed out of the blue by Colin is:
    
     lappend storage [expr {$computed_bit==1}]
    
    Funnily, the ternary operator *can* respect sharing with more complex values:
    
     set list1 [list yes yes yes]
     set list2 [list no no no]
     lappend storage [expr {$computed_bit?$LIST1:$LIST2}]
    
    All three behaviors are suprising...
    
  4. foundin changed to: "None"
  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: "ferrieux"
  10. subsystem changed to: "48. Number Handling"
  11. title changed to: "Erratic sharing/duplication of values in [expr]"
  12. type changed to: "Bug"