[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MAKE-LOAD-FORM can handle circularities [was Compilation implications]
- To: jrose@Sun.COM (John Rose)
- Subject: Re: MAKE-LOAD-FORM can handle circularities [was Compilation implications]
- From: David N Gray <Gray@DSG.csc.ti.com>
- Date: Wed, 11 Jan 89 11:38:56 CST
- Cc: Moon@STONY-BROOK.SCRC.Symbolics.COM, firstname.lastname@example.org, Common-Lisp-Object-System@SAIL.STANFORD.EDU
- In-reply-to: Msg of Tue, 10 Jan 89 19:03:49 PST from jrose@Sun.COM (John Rose)
- Sender: GRAY@Kelvin.csc.ti.com
> Simply allow the second form to contain a reference to the object
> being dumped.
> Neat, yes? File-level EQ preservation works to restore the embedded
> object reference "for free".
> Define a generic function MAKE-LOAD-FORM which takes one argument and
> returns one or two values. This function is called whenever
> COMPILE-FILE needs to dump an object whose class is of type
> STANDARD-CLASS or STRUCTURE-CLASS.
Or if its class is a user-defined metaclass, even if not a subclass of
STANDARD-CLASS. Maybe it would be best to say anything whose metaclass is
> The allocator must wholly or partially build the reconstructed object,
> and return an ordinary Lisp reference to it. The initializer, if
> supplied and non-null, must finish any initialization required by the
> object's class. It is an error if the result of this second form is not
> EQ to the result of the first.
It would be a convenient convention for the second form to return the
object, but the value returned by the second form would not actually be
used for anything, so it doesn't need to be constrained. Or maybe you
just want to verify that it did what it was intended to?
> (defclass tree-with-parent () (parent children))
> (defmethod make-load-form ((x tree-with-parent))
> `(allocate-instance (class-of x) :children ',(slot-value x 'children))
> `(initialize-instance ',x :parent ',(slot-value x 'parent))))
This isn't quite right because ALLOCATE-INSTANCE doesn't fill in any slot
values. Maybe what you want is something like
(defclass tree-with-parent () ((parent :accessor tree-parent)
(children :initarg :children)))
(defmethod make-load-form ((x tree-with-parent))
`(make-instance ',(class-of x) :children ',(slot-value x 'children))
`(setf (tree-parent ',x) ',(slot-value x 'parent))))