[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: putting CLOS objects in binfiles

   Here's my immediate problem:  I want to build objects
    which represent predicates in a special purpose query
    language, and I want them to be uniquified, like pathnames
    on the Lisp Machine.  (They cache things like compiled Lisp
    code, so it's expensive to build new copies.)  Such things
    do not dump properly, and even if a simple patch were to
    be applied (say, to dump a class symbol instead of a class),
    a simple-minded load routine would not uniquify them.

"I'm not sure that anything in Common Lisp requires that multiple
references to a single object, in a file being compiled, do not
turn into multiple objects when the file is loaded.  You might have
to address this in an implementation-dependent way unless the
definition of Common Lisp were changed to require this explicitly."

In Loops, the way we solved this problem was to provide each savable object a
unique identifier.  This UID was constructed from some representation of the
machine of ceation and the time of creation.  An object knows its UID, and from
the UID one can find the object.  For any object, the form that was dumped
includes its UID, as well as its contents.  References from a dumped object to
another object contain a form which reconstructs the pointer to object referred
to, but does not try to reconstruct its contents.  

Suppose we had an objects O1 and O2, of classes FOO and FIE respectively, each
with one slot named OTHER pointing to the other object.  Then  dumping them to a
file might create expressions like:

#,(reconstruct-object uid1 FOO OTHER #.(pointer-to-object uid2 FIE))

#,(reconstruct-object uid2 FOO OTHER #.(pointer-to-object uid1 FOO))

The result of evaluating (pointer-to-object uid2 FIE) is to create an
uninitialized object of class FIE, and make it be the value of the slot OTHER of
O1.  O1 is the object created by the first reconstruct-object form, with UID
uid1.  Evaluating the second reconstruct-object form changes the contents of the
uninititialized object.  Evaluating the form (pointer-to-object uid1 FOO) finds
the first object created.

As far as tracing through objects, we found it was better to separate out the
process of finding all objects that you want dumped (a user defined trace that
creates a list).  One then dumps each of the listed objects.  Stan Lanning
implemented a preliminary CLOS version that we have been experimenting with.