Hi,
I would like to be able to save and load results of (long) computations.
These results are stored in classes, which have arrays (of numbers),
atoms (usually numbers) and other classes as slots.
I thought of printing stuff readably and then simply loading it. But
while structures have a readable print syntax, I found nothing similar
for classes in CLHS. Is is something very tricky to do?
I also thought of simply printing a class as a (make-instance ...) form
with appropriate arguments. I am wondering what is the best way, I am
looking for something reasonably standard and viable.
Thanks,
Tamas
On Sep 15, 1:00 pm, Tamas K Papp <······@gmail.com> wrote:
>
> I would like to be able to save and load results of (long) computations.
> These results are stored in classes, which have arrays (of numbers),
> atoms (usually numbers) and other classes as slots.
>
> I thought of printing stuff readably and then simply loading it. But
> while structures have a readable print syntax, I found nothing similar
> for classes in CLHS. Is is something very tricky to do?
clos object creation can trigger various non-trivial machinery (via
MOP).
> I also thought of simply printing a class as a (make-instance ...) form
> with appropriate arguments. I am wondering what is the best way, I am
> looking for something reasonably standard and viable.
clocc/cllib/closio.lisp does this.
it prints and reads clos objects in the #[...] format.
Tamas K Papp wrote:
> Hi,
>
> I would like to be able to save and load results of (long) computations.
> These results are stored in classes, which have arrays (of numbers),
> atoms (usually numbers) and other classes as slots.
You probably mean that they are stored in *instances* of those classes...
> I thought of printing stuff readably and then simply loading it. But
> while structures have a readable print syntax, I found nothing similar
> for classes in CLHS. Is is something very tricky to do?
>
> I also thought of simply printing a class as a (make-instance ...) form
> with appropriate arguments. I am wondering what is the best way, I am
> looking for something reasonably standard and viable.
I think the second option (saving objects as MAKE-INSTANCE forms) is the
easiest one to implement, and probably the most common. You could easily
come up with a simple way of specifying which slots should (or should
not) be saved, and how, and then you could write a generic SAVE-OBJECT
method that does that for you. If you wanted to you could also easily
define a reader macro that expands into a MAKE-INSTANCE, just as #S does
for structures, but that would just be a cosmetic change.
The thing you need to worry about is the case in which the value of a
slot one object is another object and you want to save both, as you seem
to imply above. In this case you have to be careful about saving objects
in the right order and reestablishing their relationships at load time.
Another issue is shared data (e.g. two different objects holding
pointers to the same string), but I don't know if this is an issue in
your case.
Or, just use one of the available packages that add persistence to CLOS.
Alberto
In article <··············@mid.individual.net>,
Tamas K Papp <······@gmail.com> wrote:
> Hi,
>
> I would like to be able to save and load results of (long) computations.
> These results are stored in classes, which have arrays (of numbers),
> atoms (usually numbers) and other classes as slots.
>
> I thought of printing stuff readably and then simply loading it. But
> while structures have a readable print syntax, I found nothing similar
> for classes in CLHS. Is is something very tricky to do?
>
> I also thought of simply printing a class as a (make-instance ...) form
> with appropriate arguments. I am wondering what is the best way, I am
> looking for something reasonably standard and viable.
>
> Thanks,
>
> Tamas
there are tools for dumping objects. Google for: save objects lisp.
--
http://lispm.dyndns.org/
On Sep 15, 7:16 pm, Rainer Joswig <······@lisp.de> wrote:
> In article <··············@mid.individual.net>,
> Tamas K Papp <······@gmail.com> wrote:
>
>
>
> > Hi,
>
> > I would like to be able to save and load results of (long) computations.
> > These results are stored in classes, which have arrays (of numbers),
> > atoms (usually numbers) and other classes as slots.
>
> > I thought of printing stuff readably and then simply loading it. But
> > while structures have a readable print syntax, I found nothing similar
> > for classes in CLHS. Is is something very tricky to do?
>
> > I also thought of simply printing a class as a (make-instance ...) form
> > with appropriate arguments. I am wondering what is the best way, I am
> > looking for something reasonably standard and viable.
>
> > Thanks,
>
> > Tamas
>
> there are tools for dumping objects. Google for: save objects lisp.
>
I second that. We have had good results using CL-STORE, although
there may be better alternatives. YMMV.
Cheers
--
Marco
TKP> I would like to be able to save and load results of (long)
TKP> computations. These results are stored in classes, which have arrays
TKP> (of numbers), atoms (usually numbers) and other classes as slots.
the easy way is to use cl-store or some similar lib.