ZetaBase and immutable objects

Scott L. Burson gyro@zeta-soft.com
Fri, 23 May 1997 20:16:58 -0700 (PDT)

   From: hbaker@netcom.com (Henry G. Baker)
   Date: Fri, 23 May 1997 19:33:26 -0700 (PDT)

   > We already know that in an object-oriented language, a constructor need
   > not lock the object it's constructing.  

   'We' may know this, but I haven't seen such a thing discussed anywhere
   else.  Do you have any references?  The last time I brought this up to
   the CLOS crowd, they just gave me blank looks (in effect) back.
   Perhaps they hadn't thought about multiple threads.

_The_Java_Programming_Language_, Arnold & Gosling, p. 164: "The constructor
does not need to be `synchronized' because it is executed only when creating
an object, which can happen only in one thread for any given new object."

   > One can translate your proposal into
   > the rule that a constructor for an immutable object not be able to reference
   > `this' (aka `self').  I find this a more elegant formulation.
   > -- Scott

   I don't understand what rule you are proposing.  'Linear/unique'
   objects have only one reference, _period_.  I don't mean that we only
   _count_ one; there _is_ only one.  This has very obvious constraints
   on the surface syntax of the language, hence my suggestion for
   'tagging' variable names that refer to linear objects with '$' (or
   some other sort of a tag).  One would then call upon a function such
   as 'freeze-linear-into-immutable' to convert a linear object into an
   immutable, nonlinear object.

I'm thinking in terms of a traditional OO language (like Java, or good old
Flavors) where methods run "inside" objects.  Admittedly this formulation
doesn't carry over (at least not in any way that's obvious to me at the
moment) to the CLOS style where methods run "outside" objects, except for the
use of WITH-SLOTS.

But the idea is that inside a constructor in such an OO language, there is
initially no variable bound to the object being constructed.  The only way to
get one's hands on it is to use `this' (or `self' or whatever the language
calls it).  Without `this', there is only one reference to the object, which
is the implicit one.

-- Scott