[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Dumping data structures with circular references.
Date: Sat, 4 Nov 89 15:06 PST
From: Robert D. Pfeiffer <RDP@ALAN.LAAC-AI.Dialnet.Symbolics.COM>
Date: Fri, 3 Nov 89 13:57 PST
From: rsl@MAX-FLEISCHER.ILA-SF.Dialnet.Symbolics.COM (Richard Lamson)
Anyway, to the best of my knowledge, I should be reachable with the
following address:
RDP@ALAN.KAHUNA.DECNET.LOCKHEED.COM
OK, let's try it.
Date: Fri, 3 Nov 89 09:19 PST
From: Robert D. Pfeiffer <RDP@ALAN.LAAC-AI.Dialnet.Symbolics.COM>
Anyone have an idea how best to solve this? Maybe write two separate
files with SYS:DUMP-FORMS-TO-FILE and then append them after the fact?
Is it easy to append two binary files (or are there subtleties of the
file format that will screw me)? Or if I had the equivalent of
SYS:DUMP-FORMS-TO-STREAM I guess I would be home free. Then, I could
simply do my own WITH-OPEN-FILE once and call SYS:DUMP-FORMS-TO-STREAM
twice on it.
Here is a synopsis of what I did the last time I needed to do this:
(defmethod (dump database) (filename)
(si:writing-bin-file (bin-stream filename)
(si:dump-attribute-list `(:package ,(package-name *package*) :mode :Lisp) bin-stream)
(do-all-objects (object)
(si:dump-form-to-eval (creation-form object) bin-stream))
(do-all-objects (object)
(si:dump-form-to-eval (initialization-form object)))))
[...]
It's also a good idea not to put in the QUOTE if you can avoid it,
since this can make your BIN file much larger.
Really, "much larger"? I'm surprised that it's that significant.
I was too. The BIN file was about 40% bigger when I left in the quotes.
It turns out to contain three or so bytes to reference QUOTE (after the
first reference) plus a couple for the BIN-OP-LIST which constructs the
list `(QUOTE ,whatever) per object. Many of my objects were small
integers and short strings which only take a few bytes to represent in
the data file.
--------------------------------------------------------------------------------
Date: Fri, 03 Nov 89 16:45:58 -0500
From: kanderso@DINO.BBN.COM
Well, I see that each of the examples gives me enough raw material to
accomplish this task. My final concern is that both RSL and KANDERSO
use SI:WRITING-BIN-FILE, SI:DUMP-ATTRIBUTE-LIST, and
SI:DUMP-FORM-TO-EVAL. I always prefer to avoid using undocumented
functions when possible. In this case maybe I can't. Any opinions on
how safe these are to build on? For example, will I still be safe in
Release 8.0? Hopefully, in the longer term I can rewrite this stuff
using the ANSI Common Lisp MAKE-LOAD-FORM that Moon mentioned.
I don't think they will be changing the binary file dumper/loader
functions any time soon; they haven't changed since I first needed to
figure out how to do this kind of thing about 5 years ago.