Thomas A. Russ <tar@sevak.isi.edu> wrote:
+---------------
| There is further a note that this can be useful in writing
| MAKE-LOAD-FORM methods. Try
| (defmethod make-load-form ((obj rgb) &optional environment)
| (make-load-form-saving-slots obj :environment environment))
| and see if it does what you want.
+---------------
Note that depending on the implementation this might require having
*PRINT-CIRCLE* set to T for the MAKE-LOAD-FORM to work, e.g.:
cmu> (defstruct foo a b c)
FOO
cmu> (defvar *x* (make-foo :a 12 :b 'baz :c "string"))
*X*
cmu> *x*
#S(FOO :A 12 :B BAZ :C "string")
cmu> (defmethod make-load-form ((obj foo) &optional environment)
(make-load-form-saving-slots obj :environment environment))
; Compiling LAMBDA (.PV-CELL. .NEXT-METHOD-CALL. OBJ .REST-ARG.):
; Compiling Top-Level Form:
#<STANDARD-METHOD MAKE-LOAD-FORM (FOO) {489CCA95}>
cmu> *print-circle*
NIL
cmu> (make-load-form *x*)
(ALLOCATE-INSTANCE (FIND-CLASS 'FOO))
(PROGN
(SETF (SLOT-VALUE #S(FOO :A 12 :B BAZ :C "string") 'A) '12)
(SETF (SLOT-VALUE #S(FOO :A 12 :B BAZ :C "string") 'B) 'BAZ)
(SETF (SLOT-VALUE #S(FOO :A 12 :B BAZ :C "string") 'C) '"string"))
cmu>
Now that's probably *not* going to "do what you want"!! ;-}
But this may:
cmu> (setf *print-circle* t)
T
cmu> (make-load-form *x*)
(ALLOCATE-INSTANCE (FIND-CLASS 'FOO))
(PROGN
(SETF (SLOT-VALUE #1=#S(FOO :A 12 :B BAZ :C #2="string") 'A) '12)
(SETF (SLOT-VALUE #1# 'B) 'BAZ)
(SETF (SLOT-VALUE #1# 'C) '#2#))
cmu>
-Rob
-----
Rob Warnock <rpw3@rpw3.org>
627 26th Avenue <URL:http://rpw3.org/>
San Mateo, CA 94403 (650)572-2607