The integrated cross-platform development tool for ANSI Common Lisp LispWorks logo

Lisp Knowledgebase



Title: Compiled file cannot contain function objects

ID: 17019


Product: All
Version: All
OS: All

Description:
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 3.2.4.2.2) doesn't allow functions to be dumped directly since they are not externalizable objects. See
http://www.lispworks.com/reference/HyperSpec/Body/03_bdbb.htm.

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 http://www.lispworks.com/reference/HyperSpec/Body/03_dd.htm

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

Hardware:N/A
Summary:Compiled file cannot contain function objects
Bug#:
Patch Enhancement#:
Reported:

Top | Back