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

Issue: LOAD-OBJECTS (Version 1)



    Date: 6 Jan 89 11:44:25 EST (Fri)
    From: gz@spt.entity.com (Gail Zacharias)

    I take it the form returned by MAKE-LOAD-FORM is walked again by the
    file compiler, and it's the user's responsibility to avoid circularity
    (as in (defmethod make-load-form ((x y)) `',x) or equivalent multi-level
    examples).  If so, this should be stated.

I'm not sure what "walked" means, but it wouldn't be useful if the form
returned by MAKE-LOAD-FORM wasn't allowed to contain objects for which
MAKE-LOAD-FORM must be called.  Also you're right that if the user causes
infinite recursion the process won't terminate.  We shouldn't assume the
reader can figure these things out on his own, so I'll say something when
I edit the writeup.

    It would be useful to make the simple slot-recreation function available as
    part of the language.  Something like
       (slot-reconstruct-form x) -> (make-instance '<class-name> :a <a> ...)
    so they can do
       (defmethod make-load-form ((x my-class)) (slot-reconstruct-form x))
    The reason for this, aside from making things simpler for users doing
    simple things, is that the obvious MAKE-LOAD-FORM doesn't work well with
    inheritance.  That is, if a user writes
      (defclass person ()
	 ((name :reader person-name)
	  (age :reader person-age)))
      (defmethod make-load-form ((jrandom person))
	 `(make-instance ',(class-name (class-of jrandom))
			:name ',(person-name jrandom)
			:age ',(person-age jrandom)))
    as recommended by the examples, and then does
       (defclass astronaut (person)
	  ((helmet-size :initarg 17)))
    without specifing a make-load-form, then he's going to quietly lose dumping
    astronauts in a very difficult to detect way.

I was thinking that CLOS metaobjects made slot-reconstruct-form so easy
to write on one's own that there was no reason to build it in.  But perhaps
Gray's example shows that I was underestimating the complexity.