[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CLOS slot access
- To: Brad.Myers@a.gp.cs.cmu.edu
- Subject: Re: CLOS slot access
- From: Gregor.pa@Xerox.COM
- Date: Wed, 29 Jun 88 11:12 PDT
- Cc: commonloops.pa@Xerox.COM, bam@a.gp.cs.cmu.edu
- Fcc: BD:>Gregor>mail>outgoing-mail-2.text.newest
- In-reply-to: <1988.6.28.16.40.45.Brad.Myers@A.GP.CS.CMU.EDU>
- Line-fold: no
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)
....
)
(:accessor-prefix))
(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
of:
(pprint (walker::walk-form '(defmethod bar ((f foo))
(clos::with-slots* (slot1) f
(setf slot1 3)
(+ 6 slot1)))))
-------