[Newbies] 'locking' an object

Matthew Fulmer tapplek at gmail.com
Thu Oct 2 19:44:36 UTC 2008


On Thu, Oct 02, 2008 at 02:55:34PM -0400, Sean Allen wrote:
> 
> On Oct 2, 2008, at 1:18 PM, Bert Freudenberg wrote:
> 
> >> If you wanted to take a mutable object and make it immutable and be  
> >> able to go back again to mutable,
> >> how could you do that?
> >
> > What is your use case?
> 
> use case.
> 
> system needs to track changes to itself.
> 
> one option that has come up is...
> 
> linked list of different 'versions' of same object.
> head is the live object. everything else past versions.
> 
> want to mutate object? you have to 'unlock'.
> unlocking gives you a new copy and updates the linked list,
> allowing all the accessors that mutate state to work.
> 
> when locked, calling one of those accessors would result in
> an error. but when locked, read access still needed.
> 
> if i can find a way to put this in a superclass and have
> children get the functionality w/o doing anything else,
> then i really like it.

heh. I'm making something that creates a new object version
whenever an ivar is changed. I'm using tweak's fields and
compiler to do it, so it will only work in a Croquet image.
Not to mention that I've just barely started. The code is at

http://croquet-src-01.oit.duke.edu:8886/RayTracing/Quansi-Core-mtf.10.mcz

-- 
Matthew Fulmer -- http://mtfulmer.wordpress.com/


More information about the Beginners mailing list