Lisp Knowledgebase

Title: Compiled file cannot contain function objects

ID: 17019

Product: All
Version: All
OS: All

The following code cannot be compiled to a file (that is, by compile-file):

(in-package "CL-USER")

(defvar *foo* nil)

(defmacro def-foo ((foo))
 (labels ((make-foo ()
            (list :baz (compile nil #'(lambda (a) (+ a a))))))
   `(setq *foo* '(,foo ,(make-foo)))))

(def-foo (:foo))

The reason for this is that ANSI Common Lisp (section doesn't allow functions to be dumped directly since they are not externalizable objects. See

LispWorks 4.2 generates the following error on an attempt to generate a compiled file from the above:

**++++ Error in (TOP-LEVEL-FORM 2):
 System error 43 in function SYSTEM::DUMP-UNDUMPABLE-ERROR applied to (#<function (SUBFUNCTION 1 DEF-FOOB1) 20622C82> #<Fasl #<STREAM::LATIN-1-FILE-STREAM C:\temp\foo.fsl> >):
      Don't know how to dump object.

This message is unhelpful: there will be a more explanatory error message in future releases.

Also, environment objects (values of &environment argument) cannot be dumped ina compiled file, since they have dynamic-extent (ANSI Common Lisp, section 3.4.4). See

See Also:
Workaround: Change your code to create the function objects at load time instead.

Summary:Compiled file cannot contain function objects
Patch Enhancement#:

Company     Contact     Privacy Policy     Terms of Use