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

Gary Byers gb at clozure.com
Sat Jan 3 15:11:11 PST 2004



On Sat, 3 Jan 2004, Sven Van Caekenberghe wrote:

> 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...


The function CCL::%SHARED-INITIALIZE is looking at the wrong local
variable: it binds NEWVAL to the value associated with the initform,
then checks the type of another (unrelated) varable (NEW-VALUE).

Whoops.

>
> Sven



More information about the Openmcl-devel mailing list