[Openmcl-devel] Is this a bug?

Alexey Veretennikov txm.fourier at gmail.com
Tue Feb 7 22:33:10 UTC 2017


Hi,

Doesn't look like a bug. According to the documentation:
------------
Any slots indicated by slot-names that are still unbound at this point
are initialized according to their :initform forms. For any such slot
that has an :initform form, that form is evaluated in the lexical
environment of its defining defclass form and the result is stored into
the slot. For example, if a before method stores a value in the slot,
the :initform form will not be used to supply a value for the slot.
------------
Let's do the same but verifying if the slot is bound:

COMMON-LISP-USER> (DEFCLASS FOO () ((X :accessor foo-x :INITFORM 123)))
#<STANDARD-CLASS FOO>
COMMON-LISP-USER> (setf foo (make-instance 'foo))
#<FOO #x3020012B75AD>
COMMON-LISP-USER> (slot-boundp foo 'x)
T
COMMON-LISP-USER> (setf (foo-x foo) nil)
;Compiler warnings :
;   In an anonymous lambda form at position 13: Undeclared free variable FOO
NIL
COMMON-LISP-USER> (foo-x foo)
NIL
COMMON-LISP-USER> (slot-boundp foo 'x)
T
COMMON-LISP-USER> (shared-initialize foo t)
#<FOO #x302001290D2D>
COMMON-LISP-USER> (foo-x foo)
NIL
COMMON-LISP-USER> 


Ron Garret <ron at flownet.com> writes:

> ? (DEFCLASS FOO () ((X :accessor foo-x :INITFORM 123)))
> #<STANDARD-CLASS FOO>
> ? (setf foo (make-instance 'foo))
> #<FOO #x302001F7ABFD>
> ? (foo-x foo)
> 123
> ? (setf (foo-x foo) nil)
> NIL
> ? (foo-x foo)
> NIL
> ? (shared-initialize foo t) ; I would have expected this to set X back to 123
> #<FOO #x302001F2BAAD>
> ? (foo-x foo)
> NIL
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel

-- 
Br,
/Alexey


More information about the Openmcl-devel mailing list