[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Persistant CLOS Object Store
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
I was hoping a real authority would answer your query. Since they
haven't come forward, I'll do my best. There are a few steps.
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?
The only fly in the ointment is the availability of ACL 4.1. We have a
beta version. The released version was announced as available a month
ago, but we haven't received it yet.
If you can't get ACL 4.1, there are systems for accomplishing this
task which were discussed on the news group comp.lang.clos. You might
check there.
Good luck and let me know if you have quesions.
-Jeff
Jeff Berger |USmail: Ryerson 256
berger@cs.uchicago.edu | Artificial Intelligence Lab
PH: (312) 702-8584 | 1100 East 58th Street
FX: (312) 702-8487 | Chicago, IL 60637