From: Alexandre F. <ale...@gm...> - 2008-01-24 23:12:33
|
Hello, Please find attached an experimental Mutability patch against 8.5.0. FWIW, I followed Neil's advice in restricting mutations to explicit commands to avoid bad surprises. Only the syntax and implementation allow for maximal reuse of existing code through a command prefix [mutant]: set l [mutable [list 1 2 3]] set n $l set x [lreplace $l 1 1] ;# touches neither $l nor $n mutant lreplace $l 1 1 ;# touches both which become {1 3} The patch includes the following: - The [mutable] command making a mutable copy of a given list - The [mutant] command prefix enabling mutations in the child list op - The internal machinery for making it consistent with EIAS (list of stringified mutables + mass invalidation on mutation) - The [debugobj] command to help analyze what happens It passes the test suite (that one was easy, since nothing is changed in the absence of [mutable] object creation). Remarks: - So far I have ony done the List part, not the Dict one. But I think it sufficient as a proof of concept (especially considering the probability of rejection ;-) - What should be interp-wide is actually process-wide. So don't use it with threads or slave interps. Same remark as above. - As you know, the [lrange] and [lsort] functions don't mutate anything, even under [mutant] steroids, because it is in their DNA to be non-violent ;-) - I am a newbie with diff options for patches, especially under msys. The patch contains a new file "tclMutable.c" but diff would not print its contents even with -N or -P. So I cheated and put a 0-sized copy in the reference directory. Also, I did not include the obvious Makefile change of adding tclMutable.o. Sorry for the induced hand-tweaking. Thanks in advance for a tutorial on patch production. I know that some (many) of you pinch their nose over this. I only hope that giving it a try may shed a slightly different light. In particular, look at the simplicity of the new idioms, and also at the very small size of the patch (high reuse). Any hands-on comment *much* appreciated ! -Alex |