Skip to content
Tcl Source Code History Of Ticket 1881766
Login

History Of Ticket 1881766

Artifacts Associated With Ticket 1881766

  1. Ticket change [56306d3c8d] (rid 94276) by ferrieux on 2008-01-29 12:11:41:

    1. assignee initialized to: "msofer"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      This experimental patch, which could make it to a TIP eventually, adds optional "mutability" to container values (Lists, but the same could be done to Dicts).
      
      This means that when explicitly requested by the programmer (by the command prefix "mutant"), in-place operations may occur regardless of the sharedness of the object. Hence several other values may be simultaneously updated.
      
      The purpose is to allow passing a deeply nested substructure and modifying it in-place, without knowledge of its surroundings.
      
      Here are a few examples illustrating usage:
      
        # create a mutable
        set m [mutable [list 1 2 3]]
        # let another var hold it
        set n $m
      
        # mutate it
        mutant lappend m 4
        puts $m --> 1 2 3 4
        puts $n --> 1 2 3 4
      
        # use it like an immutable in all unaware code (no "mutant")
        lappend n 5 ;# this forks an immutable snapshot
        puts $n --> 1 2 3 4 5
        puts $m --> 1 2 3 4 (mutable value untouched)
      
        # now a deeper substructure
        set m [mutable [list 1 2 3]]
        set n [mutable [list 4 5 6]]
        set p [mutable [list 7 8 9]]
        mutant lappend m $n
        mutant lappend n $p
        puts $m --> 1 2 3 {4 5 6 {7 8 9}}
        mutant lset p 1 foo
        puts $m --> 1 2 3 {4 5 6 {7 foo 9}}
      
        # the cases that are not yet forbidden, but shoud shortly be:
        set l [list 1 2 3 [mutable [list 4 5 6]]] ;# contagion violation
        set m [mutable [list 1 2 3]];mutant lappend m $m; # cycle
      
    4. foundin initialized to: "TIP Implementation"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "ferrieux"
    10. subsystem initialized to: "10. Objects"
    11. title initialized to: "Mutability"
    12. type initialized to: "Patch"
  2. Ticket change [a3c32aa224] (rid 110095) by ferrieux on 2008-01-29 19:11:42:

    1. icomment:
      
      
      File Added - 264123: mutability850.patch
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  3. Ticket change [fd303ccdd8] (rid 108374) by ferrieux on 2008-01-29 19:12:49:

    1. icomment:
      
      
      File Added - 264124: mutability851rc0.patch
      
      Logged In: YES 
      user_id=496139
      Originator: YES
      
      File Added: mutability851rc0.patch
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  4. Add attachment "mutability850.patch" [c76b5ac950] (rid 121928) by ferrieux on 2008-01-30 07:16:31.

  5. Ticket change [1b31f8bc5f] (rid 123102) by ferrieux on 2008-01-30 07:16:31:

    1. icomment:
      
      
      File Added - 264230: mutability850.patch
      
      Logged In: YES 
      user_id=496139
      Originator: YES
      
      File Added: mutability850.patch
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [e9861bafc8] (rid 104829) by ferrieux on 2008-01-30 07:18:15:

    1. icomment:
      
      
      File Deleted - 264124: 
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  7. Ticket change [381bb740ba] (rid 112150) by ferrieux on 2008-01-30 07:18:16:

    1. icomment:
      
      
      File Deleted - 264123: 
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  8. Add attachment "mutability851rc0.patch" [99cdba33b9] (rid 110853) by ferrieux on 2008-01-30 07:22:15.

  9. Ticket change [9c139e23fd] (rid 111218) by ferrieux on 2008-01-30 07:22:17:

    1. icomment:
      
      
      File Added - 264232: mutability851rc0.patch
      
      Logged In: YES 
      user_id=496139
      Originator: YES
      
      Update:
        - properly per-interp and mutexed => thread- and slave- safe
        - debug info under the control of ::tcl_traceMutable
        - Mass Invalidator list is made of Tcl_Obj to reuse allocator
        - test suite OK including mutability.test
      
      Todo: contagion; acyclicity; Dicts
      File Added: mutability851rc0.patch
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  10. Ticket change [2891dc2baa] (rid 88716) by ferrieux on 2008-03-08 23:50:24:

    1. closedate changed to: "2008-03-08T16:50:24"
    2. closer changed to: "ferrieux"
    3. icomment:
      Logged In: YES 
      user_id=496139
      Originator: YES
      
      Miguel found a conceptual show stopper: iterators.
      
      Indeed, the caller and the callee of a mutability-unaware iterator (like [foreach], which could be made mutability-aware, but extensions are allowed to declare other similar unaware functions) can cooperate to render invalid pointers kept locally in the iterator's implementation (like a pointer into a mutable list's elements array).
      
      The bottom line is that "cheating" with Tcl_IsShared is fundamentally problematic. Hence the only sound way of promoting in-place operations is to make it relatively easy to render objects truly unshared, through idioms like upvarring a global, *and* to implement optimized in-place modes wherever it is useful, like in [lrange] (see patch 1890831).
      
      Consequently, I close this tracker entry.
      
      
    4. login: "ferrieux"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "ferrieux"