From: Tamas K Papp
Subject: save and load data
Date: 
Message-ID: <6j7iljF1rsk5U1@mid.individual.net>
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

From: sds
Subject: Re: save and load data
Date: 
Message-ID: <2f3521cf-6687-40ba-9a0e-427e8960409d@73g2000hsx.googlegroups.com>
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.
From: Alberto Riva
Subject: Re: save and load data
Date: 
Message-ID: <gam5dn$eo0u$1@usenet.osg.ufl.edu>
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
From: Rainer Joswig
Subject: Re: save and load data
Date: 
Message-ID: <joswig-548F66.19161715092008@news-europe.giganews.com>
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/
From: Marco Antoniotti
Subject: Re: save and load data
Date: 
Message-ID: <0ce5b62a-f6da-4d84-be6b-ab69371a9f11@e39g2000hsf.googlegroups.com>
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
From: Alex Mizrahi
Subject: Re: save and load data
Date: 
Message-ID: <48cebb56$0$90270$14726298@news.sunsite.dk>
 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.