From: Lars R. N. <lar...@gm...> - 2008-10-22 07:45:00
|
lnostdal@blackbox:~/programming/lisp/temp$ cat clos-test.lisp (eval-when (:compile-toplevel :load-toplevel :execute) (setf (find-class 'test) nil) (unintern 'test)) (declaim (optimize speed)) (defclass test () ()) (defun test (x) (declare (test x)) (princ (type-of x))) lnostdal@blackbox:~/programming/lisp/temp$ sbcl --no-userinit --eval '(compile-file "clos-test.lisp")' This is SBCL 1.0.21, an implementation of ANSI Common Lisp. More information about SBCL is available at <http://www.sbcl.org/>. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. ; compiling file "/home/lnostdal/programming/lisp/temp/clos-test.lisp" (written 22 OCT 2008 09:40:38 AM): ; compiling (SETF (FIND-CLASS #) ...) ; compiling (UNINTERN (QUOTE TEST)) ; compiling (DECLAIM (OPTIMIZE SPEED)) ; compiling (DEFCLASS TEST ...) ; compiling (DEFUN TEST ...) ; file: /home/lnostdal/programming/lisp/temp/clos-test.lisp ; in: DEFUN TEST ; (DEFUN TEST (X) (DECLARE (TEST X)) (PRINC (TYPE-OF X))) ; --> PROGN EVAL-WHEN SB-IMPL::%DEFUN LOCALLY SB-C::%FUNCALL ; --> MULTIPLE-VALUE-BIND LET UNLESS IF ; ==> ; (TYPEP #:G4 'TEST) ; ; note: can't open-code test of unknown type TEST ; ; compilation unit finished ; printed 1 note ; /home/lnostdal/programming/lisp/temp/clos-test.fasl written ; compilation finished in 0:00:00 * ..I keep wrapping defclass forms in eval-now to avoid this note, but should it be like this? Quoting from defclass in the HyperSpec: "If a defclass form appears as a top level form, the compiler must make the class name be recognized as a valid type name in subsequent declarations (as for deftype)...". It does seem to partially know(?) that this is a type since it doesn't throw an error. I mean, doing something like: (defun test (x) (declare (something-totally-unknown x)) (princ (type-of x))) ..throws an error; I'm not using the (type something-totally-unknown x) form. -- Lars Rune Nøstdal || AJAX/Comet GUI type stuff for Common Lisp http://nostdal.org/ || http://groups.google.com/group/symbolicweb |