|
From: Sam S. <sd...@gn...> - 2003-02-20 19:15:18
|
> * In message <9F8...@G8...> > * On the subject of "[clisp-list] CLOS: class-wide slots defined at compile-time?" > * Sent on Thu, 20 Feb 2003 17:52:21 +0100 > * Honorable "Hoehle, Joerg-Cyril" <Joe...@t-...> writes: > > Sam wrote: > >An alternative would be to add a class prototype (which would waste an > >instance for each class...) > > The class-prototype hack(?) may be something > 2) which seems to be somewhat standard in CLOS (I guess from your > wording), whereas SHARED-SLOT would be specific to CLISP. it's in MOP. > Maybe a separate weak hash-table trick may allow to implement a > singleton class-prototype for all classes for which one was requested > without spending an extra slot on each class? > (defvar clos:*class-prototypes* (make-hash-table :Test #'eq :weak :keys)) > ; weak so as not to grow unnecessarily > (defun class-prototype (class) > (check-type class 'standard-class) > (or (gethash class *class-prototypes* nil) > (setf (gethash class *class-prototypes) > (make-weird-instance-full-of #<unbound> slots except for the shared ones or whatever-is-needed)))) > Or maybe that class-prototype should not be an instance of its class > (but of some other one). Would that be against programmer's > expectations?? it's better to keep the prototype inside the CLASS struct. class may be redefined &c. we may create the prototype on demand. -- Sam Steingold (http://www.podval.org/~sds) running RedHat8 GNU/Linux <http://www.camera.org> <http://www.iris.org.il> <http://www.memri.org/> <http://www.mideasttruth.com/> <http://www.palestine-central.com/links.html> MS DOS: Keyboard not found. Press F1 to continue. |