Hi, Nikodemus
The QUOTE in "'a-subclass" is actually a typo. Actually I'm compiling this in my last post:
(in-package :cl-user)
(defclass a-subclass (a-class) ())
(defclass a-class () ((slot :type a-subclass)))
I didn't even declaim a (optimize safety) ...
--binghe
在 2011-3-20,09:38, Nikodemus Siivola 写道:
On 20 March 2011 03:06, Zach Beane xach@xach.com wrote:
"Chun Tian (binghe)" binghe.lisp@gmail.com writes:
(defclass a-class () ((slot :type 'a-subclass)))
(defclass a-subclass (a-class) ())
When compiling the first class definition, SBCL warn that the type A-SUBCLASS haven't been defined
I can't reproduce. Is this an oversimplification of your actual problem?
Me neither, but...
(declaim (optimize safety))
(defclass a-class () ((slot :type 'a-subclass)))
(defclass a-subclass (a-class) ())
(defmethod foo ((x a-class) y) (setf (slot-value x 'slot) y))
gives:
; caught WARNING: ; Undefined type 'A-SUBCLASS. The name starts with QUOTE: probably use of a ; quoted type name in a context where the name is not evaluated.
Replace 'a-subclass with a-subclass, and modern (1.0.45.11 or later, I would guess) SBCL is silent and happy. (Though really SBCL _should_ complain about the quote even without the OPTIMIZE SAFETY and DEFMETHOD FOO...) :P
Cheers,
-- Nikodemus