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

Comments about PCL 12/2/86



The message of 12/4/86 about "changes to PCL on the horizon" sketched
some of the changes that will be happening to PCL.  I'm currently
working with the 12/2/86 version of PCL and I'm not sure how well it
is supposed to reflect the changes that this message implied would be
happening.  But I have compiled here a list of "discrepancies" that I
have found, along with some comments and a possible bug.  I hope this
is helpful.

1) The proposed version of PCL states that no constructor function
will be created unless explicitly requested.  This is not true in the
current version.

2) Similar to the above, the proposed version states that named
predicates must be defined by hand.  However, the current defclass
does this for you.

3) This is picky, but in the examples where the allocation slot
option is used, the value given to the option is not a keyword, i.e.
the value is "class" instead of ":class."  Right now you can't specify
"class" as the allocation--you must use the keyword.  Is this a typo,
or is this really going to change?

4) I ran into a problem with the default printing method.  It seems
that this method performs a funcall on the slot accessor for each slot
in the object, without checking to see if the slot has an accessor
method defined for it, which leads to an error.  Perhaps it should
perform this check.  I know you can get around it be defining a
separate print-instance method, but I don't think it should be
necessary to have to define one for every class which may have a slot
with no accessor.  (On the other hand, I feel that having a slot
without an accessor is a little silly--why bother having the slot at
all?  Maybe you can enlighten me on this subject.)

5) I'm a little confused as to how the :initform option can be used.
Where the initform is discussed in the message, it is stated that
initial forms can be provided in two ways as shown below:
(slotname <form>) or (slotname :initform <form> ...)

But what about the following, which is used in the examples given in
the message?
(slotname <form> ...)
I tried to do this and got an error.  It seems that defclass expects
that if you have more than two things in a slot description, you have
to use :initform.  I made the change to expand-defclass shown below to
make this work.  As an aside, can you say something like
(slotname :allocation :class ...), where you specify the allocation
and possibly other options but leave the initial value undefined? 

(defmethod expand-defclass ((metaclass class) name includes slots options)
  (keyword-parse ((accessor-prefix nil accessor-prefix-p)) options
    (when (and accessor-prefix-p
	       (not (or (null accessor-prefix)
			(symbolp accessor-prefix))))
      (error "The :accessor-prefix option, when specified must have either~%~
              have an argument which is a symbol, or no argument at all."))
    (setq slots (iterate ((slot in slots))
		  (collect (if (and (listp slot)
				    (cddr slot))
			       (let ((initform-p (memq :initform (cdr slot))))
				 (if initform-p
				     (list* (car slot) (cadr initform-p) (cdr slot))
				     slot))
;			       (let ((initform
;				       (cadr (memq :initform (cdr slot)))))
;				 (list* (car slot) initform (cdr slot)))
			       slot))))
    `(ndefstruct (,name (:class ,(class-name metaclass))
			(:include ,includes)
			,@(and accessor-prefix-p
			       `((:conc-name ,accessor-prefix)))
			(:generate-accessors ,(and accessor-prefix-p
						   'method))
			,@options)
     ,@slots)))
-------