Newsgroups: comp.lang.lisp
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!gatech!swrinde!howland.reston.ans.net!Germany.EU.net!Frankfurt.Germany.EU.net!news.maz.net!news.ppp.net!news.Hanse.DE!wavehh.hanse.de!cracauer
From: cracauer@wavehh.hanse.de (Martin Cracauer)
Subject: Re: Binary input/output of Common Lisp objects
Message-ID: <1996Feb26.090637.24542@wavehh.hanse.de>
Organization: BSD User Group Hamburg
References: <51hgwiuizj.fsf@apogee.nrl.navy.mil>
Date: Mon, 26 Feb 96 09:06:37 GMT
Lines: 37

healy@apogee.nrl.navy.mil (Liam Healy) writes:

>I would like to do unformatted, or binary, input and output of CL
>objects (arrays, structures, numbers, etc.).  Symbolics CL has a
>function dump-forms-to-file which allows you to dump an object to a
>file that can be reloaded later.  Is there anything in CL that is
>analogous?  I have seen CLOS's make-load-form, but it appears one must
>define it, and I don't see how to do that.

A portable solution would be to write the data to a file, compile that
and load it later. Loading such a data structure is four times as fast
as loading the Ascii representation (for my applications), but
still not comparable to the speed of loading structes in C.

You can use (read-sequence ...) and (write-sequence ...) when
provided. Those can work in constant space and can be very fast.

>A related but slightly different question is, can I read/write a
>machine-native datum such as a floating point number such that it can
>be read/written unformatted in another language like Fortran.

>I am using CMUCL on an SGI but I would prefer a portable solution if
>possible.  Thanks for any help.

Most compilers use tagged formats for direct values (ints, doubles),
so their internal representation is incompatible with those of the
native machine.

If you have to tangle with such problems often, you should consider
using C functions to do your I/O.

Martin
-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <cracauer@wavehh.hanse.de>  -  Fax +49 40 522 85 36
 BSD User Group Hamburg, Germany   -   No NeXTMail anymore, please.
 Copyright 1995. Redistribution via Microsoft Network is prohibited
