[erlang-questions] Theoretically Stuck

Richard A. O'Keefe ok@REDACTED
Wed Sep 6 07:04:03 CEST 2006


Jay Nelson <jay@REDACTED> wrote:
    a LOVELY analysis of the problem.

I'd just like to add one more empirical observation.
The Smalltalk system I know best is Squeak.
The Squeak GUI system (more precisely, one of the Squeak GUI systems,
it still supports the old MVC system from Smalltalk-80) is called
Morphic, and is modelled on the Morphic system in Self.

Now in Self there are no such things as classes, objects inheriting
"slots" from other objects, so there is no particular reason why each
object couldn't have a _different_ collection of slots.  And in Self
an object may acquire new slots at any time without changing its identity.

That resulted in a design where there were quite a few slots that most
GUI objects had, but there were even more slots that *many* GUI objects
had some subset of, and some objects might have completely unique slots.

This isn't schema evolution, more like schema chaos, but in Morphic it
all seems to work out.

While Self is objects-and-inheritance-without-classes, Squeak is your
classic single-inheritance class-based Smalltalk.  So how can this kind
of variability be modelled in such a system?

Answer:  the slots which every GUI object needs, are modelled as
conventional instance variables, plus there is another instance variable
holding a hash table.  Whenever a Morph is given a non-default value for
one of those slots, the hash table is created if necessary and the value
put there.  The occasional object-specific slot can go there too.

My point?  The dictionary-based approach that Jay Nelson described is
not just something one would invent for Erlang, it's _used_ in more
conventional OO languages.  (The papers I read years ago about the
DIANA notation for modelling Ada programs used an inside-out version
of this which works better in strictly typed languages:  instead of
each object having its own hash table for non-default but rare slots,
there was one hash table for each such slot going from objects to
values.  In a garbage collected language, which Ada needn't be, you
need weak hash tables for that.  The per-object hash table approach
doesn't need weak tables.)




More information about the erlang-questions mailing list