[comp.lang.clos] save-object etc.

john@LINUS.MITRE.ORG (05/09/91)

I wondered why the CLOS save-object code didn't use MAKE-LOAD-FORM and
cousins, as defined in CLtL2.

A number of people rightly noted that not all Lisps support this
facility yet.  What I was suggesting was that SAVE-OBJECT be written
so as to call MAKE-LOAD-FORM, even if your Lisp doesn't have it.  That
is, essentially write MAKE-LOAD-FORM methods instead of having a big
conditional in GET-FASD-FORM.  That way, when your Lisp supports
MAKE-LOAD-FORM, you're all set.  This supposed that you can define
MAKE-LOAD-FORM methods on built-in classes, as Kerry Koitzsch
(kerry@ads.com) pointed out.  Unfortunately, I just noticed that page
660 of CLtL2 says:

  It is valid for user programs to call MAKE-LOAD-FORM in
  circumstances other than compilation, providing the argument's
  metaclass is not BUILT-IN-CLASS or a subclass of BUILT-IN-CLASS.

which means that (MAKE-LOAD-FORM *MY-HASH-TABLE*) is not valid code.
Sigh.  What good is MAKE-LOAD-FORM if I can't recursively include the
load forms of built-in objects?

David Gadbois (AI.gadbois@MCC.COM) wrote:

  Also, the CLOS dumper presented prints out a character
  representation, which may be advantageous in some situations.  I
  have not tried it, but it looks like the output will be portable
  between implementations unlike the results of MAKE-LOAD-FORMs.

That's certainly true for compiled code, which is why, in retrospect,
using the compiler and the notion of "similarity as constants" as I
suggested is only of medium interest.  On the other hand, writing the
results of a MAKE-LOAD-FORM call to a file and loading that source
file ought to work, providing no BUILT-IN-CLASSes are involved.
Which, of course, seems unlikely.

I also suggested that this facility could be implemented by compiling
code that contained the object you wanted to save, and then loading
that code later.  David Gadbois continues:

  I am a bit suspicious about what "similarity as constants" means for
  structures and instances.  ... it is not clear to me whether this
  allows implementations to put objects constructed via MAKE-LOAD-FORM
  in read-only areas.

You're right.  I forgot that it's illegal to destructively modify any
constant in executable code (CLtL2, page 115), for good reasons like
the one you suggested.  This makes my second idea pretty useless as
well.  Sigh.

Finally, Jeff Dalton (jeff@aiai.edinburgh.ac.uk) pointed out that
CLtL2 is just a book, not a definition.  It's effectively a snapshot
of what the ANSI committee had come up with at some point last year.
In fact, some of the new material in CLtL2 is arguably NON-STANDARD,
as the commitee has (completely appropriately) rescinded some of their
decisions.

Given that, why are vendors coming out with these new CL versions?
Lately, I'm spending all my time rewriting my 50,000 line system so
that it at least loads.

John Burger

Gregor@parc.xerox.com (Gregor Kiczales) (05/09/91)

   Posted-Date: Wed, 08 May 91 18:19:30 -0400
   Date: 	Wed, 8 May 1991 15:19:30 PDT
   From: john@linus.mitre.org

   which means that (MAKE-LOAD-FORM *MY-HASH-TABLE*) is not valid code.
   Sigh.  What good is MAKE-LOAD-FORM if I can't recursively include the
   load forms of built-in objects?

Instead of recursively including the load form of the built in objects,
just include the objects themselves.  Then, the dumper will call
MAKE-LOAD-FORM on those objects itself.