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:
bounds origin: newBounds origin.
bounds corner: newBounds corner.
origin x: aPoint.
origin y: aPoint.
etc. and if we simplify the explicit assignments here, we might as well
bounds <- newBounds.
origin <- aRectangle origin.
corner <- aRectangle corner.
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
^anObject species new <- anObject
Or, alternatively, if you know if some object is currently "owned" or not,
you might do something like:
"if the object is owned by someone get a new copy,
if not, then just use it"
ifTrue:[^anObject species new <- 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 ;-)
More information about the Squeak-dev