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

Re: CLOS slot access

    Date: Tue, 28 Jun 88 12:48:18 EDT
    From: Brad.Myers@a.gp.cs.cmu.edu

    What is the fastest way to do slot accesses in CLOS?
    We are using
	    (defclass foo ()
	      (slot1 :initform NIL)

	    (defmethod bar ((f foo))
	      (clos::with-slots* (slot1) f
		 (setf slot1 3) ; setting
		 (+ 6 slot1)    ; access

This is the fastest way to do slot access in PCL, and will remain so.
But, one of the key points of my message is that you shouldn't decide
which interface to use based soley on performance, you should look at
whether the functionality is what you really want.

Two other comments:

 - there will be a new version shortly which should provide
   somewhat better slot access performance.

 - the :accessor-prefix option is now obsolete and should not
   be used in new code.

Final question.  It is possible that there is a problem with slot
access optimization in your lisp.  Could you please send me the results

  (pprint (walker::walk-form '(defmethod bar ((f foo))
                                 (clos::with-slots* (slot1) f
		                    (setf slot1 3)
		                    (+ 6 slot1)))))