Overview
| Artifact ID: | 56306d3c8d2c1de06f0b00b5ad2b4cd85a649ad7 |
|---|---|
| Ticket: | 1881766fffffffffffffffffffffffffffffffff
Mutability |
| User & Date: | ferrieux on 2008-01-29 12:11:41 |
Changes
- assignee changed to: "msofer"
- cmimetype changed to: "text/plain"
- comment changed 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 - foundin changed to: "TIP Implementation"
- is_private changed to: "0"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "ferrieux"
- subsystem changed to: "10. Objects"
- title changed to: "Mutability"
- type changed to: "Patch"