dump-forms-to-file
dumps specified forms to a fasl file. Use the Common Lisp functions make-load-form
and make-load-form-saving-slots
to control the dumping of forms.
The best way to specify the file type of the output file is to use compile-file-pathname
as in the example below. The file types currently used by LispWorks for fasl files are listed in with-output-to-fasl-file.
(defclass my-class () ((a :initarg :a :accessor my-a)))
(defmethod make-load-form ((self my-class) &optional environment)
(declare (ignore environment))
`(make-instance ',(class-name (class-of self))
:a ',(my-a self)))
(setq *my-instance* (make-instance 'my-class :a 42))
(dump-forms-to-file
(compile-file-pathname "my-instance")
(list `(setq *my-instance* ,*my-instance*)))
In another session, with the same definition of my-class
, loading the file "my-instance"
will create an equivalent instance of my-class
.