[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

:initform and :allocation :class



We've run into the following problems when using the St.
Patrick's Day release of PCL: (Symbolics)

1) Compiling or evaluating the form,

(defclass foo () ((bar :initform 'bar :allocation :class)))

creates a class whose "bar" slot is initialized to "'bar", rather than
"bar" as the CLOS specification dictates.  Further, if the quote is
left off of the argument to :initform, the compiler complains that "bar
is unknown and has been declared special" but creates a class that
behaves as if the argument was not evaluated (which turns out
to be a problem in the initfunction that is created by
cannonicalize-slot-description). 
 
The documentation indicates that an :initform that is allocated at
the class should be EVALUATED at evaluation/compile time.  This does
not take place, leading to the behavior mentioned above.

We have thought of the following fix to parse-class-slot:

(defmethod PARSE-CLASS-SLOT ((class standard-class) slot)
	.
	.
	.

    (make-slotd class
		:name name
		:keyword (make-keyword name)
		:initform (IF (EQ ALLOCATION :CLASS)
			      (EVAL INITFORM)
	                      initform)
		:initfunction initfunction
		:initargs initargs
		:allocation allocation
		:type type
		:accessors accessors
		:readers readers)))

The change is highlighted in caps.

Has anyone come across this error and come up with a better fix?

2) subtypep doesn't work on classes.  For instance:

	(defclass foo () (x y z))

	(defclass goo (foo) (blah blaz blub))

	(subtypep 'foo 'goo) => nil nil

	
	Rich Piazza