I'm trying to write a small game in (SBCL) Common Lisp, using Quickload and ASDF to define and manage dependencies. It uses CLOS, so I have a directory in project
called classes
, and in there, a file, locatable.cl
.
The defclass
form for the LOCATABLE class needs a LOCATOR parameter, so I have a line:
:initform (error "Must supply a locator parameter for this class.")
Whenever I try to load this file or quickload
the system, though, I get the error above ("Must supply a locator parameter for this class"). Since I'm trying to define a system and not creating any instances of the class, I don't understand why I'm getting this. If I comment out the error line, everything loads fine, but I was led to believe that the way I have it is a standard way of requiring an :initval
for a slot.
How do you define such a thing so you can load the file/make a system definition without actually signaling the error?
Here's the class -
(defclass locatable ()
((zone
:accessor zone
:initform nil)
(locator
:initarg :locator
:initform (error "Must supply a locator parameter for this class.")
:allocation :class
:accessor locator)))
UPDATE: I entered the form at the REPL and got the same error. For curiosity's sake, I entered it in again twice, first with :initform ""
, then with the error form. It accepted the first form, and didn't complain about the second, so this problem doesn't seem to happen on re-definition.