Squid plan

Andreas Raab andreas.raab at gmx.de
Sat May 10 15:25:58 UTC 2003


> Would it be easier to have explicit object ownership? Every 
> object has an owner. That way, a "segment" is a group of objects
> with a common owner. Alternatively, a "segment" may not have
> out-going pointers, and can only use an owning object as a sort
> of proxy should they need access to the outside world.

I've thought about this model for a while myself. I always ended up with
thinking about the "meaning of assignment" when I got deeper into it,
because at some point you may want to treat assignment more along the lines
of unification (as in Prolog) rather than pointer sharing (as in Lisp).

For example, consider we say something like:

	aMorph bounds: self bounds.

The intent of this message can be seen in two ways. Either to say "use the
object I hand you as your bounds variable" (pointer sharing) or
alternatively "make your bounds equal to what I hand you" (unification). If
we take the latter interpretation, then one way of dealing with this would
be along the lines of:

Morph>>bounds: newBounds
	bounds origin: newBounds origin.
	bounds corner: newBounds corner.

Rectangle>>origin: aPoint
	origin x: aPoint.
	origin y: aPoint.

etc. and if we simplify the explicit assignments here, we might as well
merely say:

Morph>>bounds: newBounds
	bounds <- newBounds.

Rectangle>><- aRectangle
	origin <- aRectangle origin.
	corner <- aRectangle corner.

Point>><- aPoint
	x <- aPoint x.
	y <- aPoint y.

What's interesting when you take the assignment idea is that when you start
out with an "empty object" (no existing "bounds" variable, for example) that
you might (conceptually) implement

UndefinedObject>><- anObject
	^anObject species new <- anObject

Or, alternatively, if you know if some object is currently "owned" or not,
you might do something like:

UndefinedObject>><- anObject
	"if the object is owned by someone get a new copy,
	 if not, then just use it"
	anObject isOwned
		ifTrue:[^anObject species new <- anObject]
		ifFalse:[^anObject].

There are some interesting technical properties when using unification
instead of pointer sharing. For example, it appears to me that if
unification ultimately goes down to the leafs of some object we'd get much
better "locality" of memory references. In addition, it seems as if there
should be almost no need for garbage collection (the object structure is
preserved for the most part when you only assign leafs). Etc.

Just a few weird thoughts ;-)

Cheers,
  - Andreas



More information about the Squeak-dev mailing list