[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Object Printing Discussion



Be warned, I am going to (mostly) dump on using printing for dumping.

The reason defstruct has a readable representation for printed objects
is because defstruct is broken in this (and many other) regard.  I
believe the default printed representation of defstruct types lulls
programmers into a false sense of believing that the problem of dumping
and restoring has been solved for them when in fact, that is not at all
true.

In my mind, printing an object for the user read its 'printed
representation' and dumping an object so that some other program can
restore it later are two completely different operations.  In addition,
depending on the application or mode, there may be many different ways
to do each of these.

Lets just look at dumping/restoring, what are some of the issues:

- circularity, how to deal with it?
- pointers to special "ground" objects which shouldn't be dumped but
which
  should be "re-grounded" when the object is restored.
- restoring an object but not all the objects it points to

None of these questions is terribly hard, but they all have very
different answers depending on the specific application.  Whats more,
none of these have to do with efficiency per se.  I can add efficeincy
as another problem, it only makes this more complicated.

- efficiency of dump format.  Certainly the #S format is about the least
efficient
  dump format imaginable.  It takes a lot of space, and it takes a lot
of work at
  dump and restore time.


So I guess my opinion is that it would be a mistake to try to
standardize a 'generally useful for dumping' print function.  Certainly
any class or metaclass which wants to can provide a different method for
print-object which would be the base of a whole dumping/restoring
sub-protocol.  So the hook is there for people to do whatever they want.
But I think we would be doing them a diservice to pretend that we had
provided them a general solution to this problem.

Here is a related question?

What happens if an object appears as a constant in a piece of code that
is being compiled to a file?  CLtL certainly is not clear on what
happens if a defstruct-defined structure appears in such a place.  Is
print-object what you would like to call here??