Save the following in file part0.lisp:
  (defclass SOM ()
    ((nrows)
     (ncols)
     (matrix)))

  (defun initialize-matrix (som)
    (declare (type SOM som))
    (with-slots (nrows ncols matrix) som
      (setf matrix (make-array (list nrows ncols)))
      (dotimes (i nrows)
        (dotimes (j ncols)
          (setf (aref matrix i j) (random 1000)))))
    nil)

Save the following in file part1.lisp:
  (defun belly-up ()
    (let ((som (make-instance 'SOM)))
      (initialize-matrix som)
      som))

To get thrown into the debugger, type the following in CMUCL:
  (compile-file "part0")
  (load "part0")
  (compile-file "part1")

The error message is:
  Error in function C::DUMP-STRUCTURE:  Attempt to dump invalid structure:
    #<KERNEL::STANDARD-CLASS SOM {4802C725}>
  How did this happen?
     [Condition of type SIMPLE-ERROR]

  Restarts:
    0: [ABORT] Return to Top-Level.

  Debug  (type H for help)

  (C::DUMP-STRUCTURE #<KERNEL::STANDARD-CLASS SOM {4802C725}>
                     #<Fasl-File "part-1.x86f">)
  Source: 
  ; File: target:compiler/dump.lisp

  ; File has been modified since compilation:
  ;   target:compiler/dump.lisp
  ; Using form offset instead of character position.
  (ERROR "Attempt to dump invalid structure:~%  ~S~%How did this happen?" STRUCT)
  0] 

This is the banner message after CMUCL is started:
  CMU Common Lisp CVS snapshot 2003-12, running on delphis
  With core: /usr/local/cmucl-2003-12/lib/cmucl/lib/lisp.core
  Dumped on: Sun, 2003-11-30 06:00:10-08:00 on lorien.users.earthlink.net
  See <http://www.cons.org/cmucl/> for support information.
  Loaded subsystems:
      Python 1.1, target Intel x86
      CLOS based on Gerd's PCL 2003/06/18 09:23:09

This error won't happen if the declaration in INITIALIZE-MATRIX is
commented out or the class definition of SOM is defined in another file
that is compiled and loaded before part0.lisp and part1.lisp are compiled
and loaded.

Any insight on this weird behaviour will be appreciated.

Best wishes,

-cph






Reply via email to