[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Persistant CLOS Object Store
Jeff,
I wrote
From: R.Dongha <dongha@uk.ac.umist.co.sna>
Date: Fri, 24 Apr 92 10:35:58 BST
We are developing a distributed system that runs on Sparc stations under
OpenWindows
(SunOS 4.1.1) running Allegro Common Lisp (version 4.0.1).
[description of system deleted]
The problem is how to store the CLOS objects so that they are persistant
over time and such that they can be read back into a lisp image.
Any suggestions would be greatly appreciated.
--
Regards,
Paul
your reply was
---- ----- ---
Date: Fri, 24 Apr 92 09:18:10 CDT
0.) The easiest way to accomplish what you want requires upgrading to
Allegro CL 4.1. This version of ACL implements MAKE-LOAD-FORM
described in CLtL2, p. 659. Once you've migrated to 4.1, the rest is
trivial.
1.) The next thing to do is define a MAKE-LOAD-FORM method for the objects
you wish to save. If there are no special requirements--such as slots
in an object which you do _not_ wish saved--the simplest thing is to
define a default method for all user defined objects (including
structures).
(defmethod MAKE-LOAD-FORM ((object CLOS:STANDARD-OBJECT))
(make-load-form-saving-slots object))
This method allows you to save objects that have circularities.
2.) In the running lisp image, collect the objects you wish saved in
lists pointed to by global variables, e.g. *GLOBAL-VAR1*. If the
objects are already collected under globals your code uses, you can
use those globals rather than defining new ones, if you wish. Actually,
the objects need not be CLOS objects. Any self-evaluating objects can
be saved. And the objects need not be collected in lists--hash tables,
vectors, etc. will work too.
3.) For any globals pointing to lists of objects you are saving, you will
need to have a source file (let's call it "saved.cl") containing code
of the form:
(declaim (special *GLOBAL-VAR1*))
(setq *GLOBAL-VAR1* '#.*GLOBAL-VAR1*)
4.) To save the objects, compile saved.cl.
5.) To read them back in to another lisp image, load saved.fasl.
*GLOBAL-VAR1* now points to the list of saved objects.
6.) Simple ,eh?
This works fine. However for step 5, in order to read back the saved lisp
object, the reader needs to know that *GLOBAL-VAR1* exists and ofcourse
needs to know the name of this global.
What if the reader does not know this variables name?
What I would really like to do is to simply load saved.cl and have the
load function RETURN the CLOS object stored in
saved.cl. (Note that I only store one CLOS object in every file).
Is there a good way of doing this. (I hope this all makes sense.)
Thanks in advance,
--
Regards,
Paul
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Paul Dongha, Email: dongha@sna.co.umist.ac.uk
Dept of Computation,
U.M.I.S.T, Manchester, Tel: (061)-200-3361
P.O. Box 88, England. Fax: (061)-200-3346
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^