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

MOP Comments Part 2.



Section: The slot inheritance protocol

	The generic function collect-slotds (class local-slots cpl) collects an
	ordered list of effective slot descriptions for this class.  It takes
	the local-slots as an argument, and recursively builds up the list of
	all slots that need to be in this class.  It calls
	compute-effective-slotd to combine multiple definitions of a single slot
	found in classes on the class precedence list.

I think that the word recursively is a mistake here, The slots should be
collected from one method.  If COLLECT-SLOTDS is called recursively, the
behavior of the slot collection will be distributed among the superclasses'
class.  Instead, the behavior should be centralized in the original class
argument of collect-slotds.  I don't know why this function needs LOCAL-SLOTS
and CPL if that's the local slots and the cpl of CLASS.

Section: The Instance Structure Protocol
I would like to see some objectives for this section:
- Do we want a metaclass writer be to able to write, portably, a new metaclass
and be able to optimize creation and slot access as much as the native
implementation of STANDARD-CLASS, or
- Do we expect the programmer to get something functional but not very
fast ?
I assume that we want to meet the first objective, because otherwise, I don't
see much value in providing something relatively complex that does not do much.

I don't have much to say about the instance allocation stuff.

About the slot access stuff: 
- OPTIMIZE-INSTANCE-ACCESS that is supposed to produce optimized code for
slot-value, slot-value-using-class, their predicates and setf functions.  It's
OK with me.

- STANDARD-INSTANCE-ACESS is supposed to be supplied by the implementation and
have the necessary optimization machinery so it is fast.  However it works on
instance slots only.  That's a bug because the method code won't know the
allocation type of a slot.  A slot can be redefined in a subclass and the method
code should work for the subclass.

- STANDARD-INSTANCE-REF, called by STANDARD-INSTANCE-ACCESS has the same bug, it
accesses instance slots only. Note that this function should accept an
NOT-BOUND-FUNCTION argument, and standard-instance-access should be written
like:
(defun standard-instance-access 
       (instance description trap missing-function not-bound-function)
  (let* ((class (class-of instance))
         (index (index-in-instance class description)))
    (cond ((null index)
           (funcall missing-function instance description))
          (t
           (standard-instance-ref instance index not-bound-function)))))
Because, in order to find out if the slot is bound, STANDARD-INSTANCE-BOUNDP 
has to access it. 

To summarize, if we want the OPTIMIZE-INSTANCE-ACCESS method to generate a call
to a non generic, implementation optimized function, this function CANNOT infer
the allocation type of the slot from its name at compile time. This needs to be
done at runtime.
 
	 Patrick.