copy-on-write (was: globals considered harmful)

Bill Burdick burdick at ars.rtp.nc.us
Fri Mar 25 06:20:08 UTC 1994


> However, there may be some clever trick to implement COW efficiently.
> Sounds like a Ph.D. thesis to me... :-)
> 
> -Urs

I sent a message about NewtonScript and copy-on-write on the 12th, but it 
doesn't look like it got through :(.

How about a blend of indirect access and the pointer redirection.  Only use 
indirect access for objects that use copy-on-write (i.e. objects that still 
inherit some slots from a prototype).  Once an object's slots are all copied, 
you redirect the pointers once to the new object.

For example, make a stub object with an inheriting slot to the COW object.  
This object inherits from the prototype and grows new slots as needed.  You 
guarantee that the only pointer to the COW object is the stub, this way, you 
don't need to use addSlotsIfAbsent:, you can just make a new object, copy the 
old slots, and reassign the stub's pointer to the new object.  When the COW 
object copies the last slot, you do a define: to make the stub effectively 
become the COW object.

This gives you the benefit of COW objects when you need them, at the expense 
of indirect access.

	-- Bill Burdick
	burdick at ars.rtp.nc.us





More information about the Self-interest mailing list