From: Krzysztof Drewniak on
I am attempting to write a serialization library. I have managed to
serialize standard-objects but am having problems deserializing them.

The deserialization method (at the point where I get lost) has the name
of the class at (first args) and a lost of the form
((slot-name1 slot-value1) (name2 value2) ...) at slots. However, I can't
figure out how to make that into an object (there MAY (or not) be
initargs, and the initforms MIGHT contian calls to error) Any help?

KRzysztof Drewniak
--
X-Real-Email-With-Antispam: krzysdrewniak at gmail dot com
pgp key on keyserver.ubuntu.com and maybe some other place too
From: Krzysztof Drewniak on
Krzysztof Drewniak <krzysdrewniakNOSPAM(a)gmai.com> writes:

> I am attempting to write a serialization library. I have managed to
> serialize standard-objects but am having problems deserializing them.
>
> The deserialization method (at the point where I get lost) has the name
> of the class at (first args) and a lost of the form
> ((slot-name1 slot-value1) (name2 value2) ...) at slots. However, I can't
> figure out how to make that into an object (there MAY (or not) be
> initargs, and the initforms MIGHT contian calls to error) Any help?
>
> Krzysztof Drewniak
I also don't want to call any :after methods on make-instance. If
implementation-dependent hackery is needed, sbcl and clisp are my
targets.

Krzysztof
--
X-Real-Email-With-Antispam: krzysdrewniak at gmail dot com
pgp key on keyserver.ubuntu.com and maybe some other place too
From: Pascal Costanza on
On 13/06/2010 16:48, Krzysztof Drewniak wrote:
> Krzysztof Drewniak<krzysdrewniakNOSPAM(a)gmai.com> writes:
>
>> I am attempting to write a serialization library. I have managed to
>> serialize standard-objects but am having problems deserializing them.
>>
>> The deserialization method (at the point where I get lost) has the name
>> of the class at (first args) and a lost of the form
>> ((slot-name1 slot-value1) (name2 value2) ...) at slots. However, I can't
>> figure out how to make that into an object (there MAY (or not) be
>> initargs, and the initforms MIGHT contian calls to error) Any help?
>>
>> Krzysztof Drewniak
> I also don't want to call any :after methods on make-instance. If
> implementation-dependent hackery is needed, sbcl and clisp are my
> targets.

You can use allocate-instance to create an instance of a class without
initializing it. This is portable Common Lisp.


Pascal

--
My website: http://p-cos.net
Common Lisp Document Repository: http://cdr.eurolisp.org
Closer to MOP & ContextL: http://common-lisp.net/project/closer/
From: Tim Bradshaw on
On 2010-06-13 15:46:18 +0100, Krzysztof Drewniak said:

> The deserialization method (at the point where I get lost) has the name
> of the class at (first args) and a lost of the form
> ((slot-name1 slot-value1) (name2 value2) ...) at slots. However, I can't
> figure out how to make that into an object (there MAY (or not) be
> initargs, and the initforms MIGHT contian calls to error) Any help?

You can use ALLOCATE-INSTANCE to create instances and fill in the slots
yourself. The downside of doing this is that you had better understand
what any code that would have been run but is now not being did - in
other words this is potentially a fairly serious abstraction violation.
As an example imagine a system where creating objects somehow
"registered" them somewhere - none of that will now happen.

From: Barry Margolin on
In article <hv3395$pid$1(a)news.eternal-september.org>,
Tim Bradshaw <tfb(a)tfeb.org> wrote:

> On 2010-06-13 15:46:18 +0100, Krzysztof Drewniak said:
>
> > The deserialization method (at the point where I get lost) has the name
> > of the class at (first args) and a lost of the form
> > ((slot-name1 slot-value1) (name2 value2) ...) at slots. However, I can't
> > figure out how to make that into an object (there MAY (or not) be
> > initargs, and the initforms MIGHT contian calls to error) Any help?
>
> You can use ALLOCATE-INSTANCE to create instances and fill in the slots
> yourself. The downside of doing this is that you had better understand
> what any code that would have been run but is now not being did - in
> other words this is potentially a fairly serious abstraction violation.
> As an example imagine a system where creating objects somehow
> "registered" them somewhere - none of that will now happen.

The "right" solution for this is to require that each class provide
serialization and deserialization methods.

Why not use the existing MAKE-LOAD-FORM protocol? Classes that require
special handling of their slots when externalizing them should define a
method for this GF. To deserialize, all you have to do is EVAL the form.

--
Barry Margolin, barmar(a)alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***