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 compile-file.
If the file pathname already exists, it is superseded.
A fasl file created using
dump-forms-to-file
must be loaded only by load-data-file, and not by
load
.
(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"
using load-data-file will create an equivalent instance of
my-class
:
(sys:load-data-file
(compile-file-pathname "my-instance"))