[Openmcl-devel] Slot :type and :initform catch-22

Sven Van Caekenberghe sven at beta9.be
Sat Jan 3 06:23:32 PST 2004


Welcome to OpenMCL Version (Alpha: Darwin) 0.14-031220!
;; Testing the typing of slots
? (defclass point () ((x :initarg :x :type number) (y :initarg :y :type 
number)))
#<STANDARD-CLASS POINT>
? (make-instance 'point)
#<POINT #x537D4BE>
? (make-instance 'point :x 1 :y 2)
#<POINT #x537D3AE>
? (make-instance 'point :x 'foo :y 'bar)
 > Error in process listener(1): value FOO is not of the expected type 
NUMBER.
 > While executing: CCL::%SHARED-INITIALIZE
 > Type :POP to abort.
Type :? for other options.
1 > :q
;; Testing typing of slots combined with an initial value
? (defclass point () ((x :initarg :x :type number :initform 0) (y 
:initarg :y :type number :initform 0)))
#<STANDARD-CLASS POINT>
? (make-instance 'point)
 > Error in process listener(1): value NIL is not of the expected type 
NUMBER.
 > While executing: CCL::%SHARED-INITIALIZE
 > Type :POP to abort.
Type :? for other options.
1 > :q
? (make-instance 'point :x 1 :y 2)
#<POINT #x53798E6>

It would seem that the combination of an :initform and a :type does not 
work,
unless I am doing something wrong - which is also quite possible...

Sven





More information about the Openmcl-devel mailing list