1 Dec 2002 19:18
DEFCONSTANT at compile time/load time
Edi Weitz <edi <at> agharta.de>
2002-12-01 18:18:18 GMT
2002-12-01 18:18:18 GMT
Hi!
I have a file foo.lisp with the following contents:
(defun foo (n)
(1+ n))
(defconstant +bar+ (foo 10))
If I try to compile it, SBCL (0.7.10 on Linux) complains:
* (compile-file "foo")
; compiling file "/tmp/foo.lisp" (written 01 DEC 2002 07:02:20 PM):
; recognizing DEFUN FOO
; compiling top level form:
; compiling DEFUN FOO:
; compiling top level form:
debugger invoked on condition of type UNDEFINED-FUNCTION:
The function FOO is undefined.
OK, that's what I expected. The CLHS says about DEFCONSTANT that
"users must ensure that the initial-value can be evaluated at compile
time". OK, let's try it again, foo.lisp now is:
(eval-when (:compile-toplevel :execute :load-toplevel)
(defun foo (n)
(1+ n)))
(defconstant +bar+ (foo 10))
(Continue reading)
RSS Feed