🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.clos
Article #532

Controlling the class of effective-slot-definition objects

#532
From: Richard Harris
Date: Fri, 03 May 1991 22:01
56 lines
2842 bytes
I want to control the class of my effective-slot-definitions
based in information in my direct-slot-definitions, but the MOP
is so vague on how compute-effective-slot-definition computes
the initargs argument to effective-slot-definition-class that
I can't figure out how to do this.  In particular, the MOP
says that compute-effective-slot-definition follows the rules
described in the "Inheritance of Slots and Options" section of
the CLOS specification to generate the initargs described
in "Initialization of Slot Definition Metaobjects", without
saying anything about how other initargs are could be generated
or how the process of generation of initargs chould be changed in
any way.

If compute-effective-slot-definition-initargs were defined in the
MOP, I could use it.


Here is how I could use PCL (since PCL has
compute-effective-slot-definition-initargs) to do what I want:

#|| ;This is how compute-effective-slot-definition is defined in PCL
(defmethod compute-effective-slot-definition ((class std-class) dslotds)
  (let* ((initargs (compute-effective-slot-definition-initargs class dslotds))
	 (class (effective-slot-definition-class class initargs)))
    (apply #'make-instance class initargs)))
||#

(defclass my-direct-slot-class (standard-direct-slot-definition)
  ((my-direct-info :initarg my-direct-info)))

(defclass my-effective-slot-class (standard-effective-slot-definition)
  ((my-effective-info :initarg my-effective-info)))

(defmethod direct-slot-definition-class ((class my-class) initargs)
  (find-class (if (getf 'my-direct-info initargs)
                  'my-direct-slot-class
	          'standard-direct-slot-definition)))

(defmethod compute-effective-slot-definition-initargs :around
      ((class my-class) dslotds)
  (let ((my-direct-info-list nil))
    (dolist (dslotd dslotds)
      (when (typep dslotd 'my-direct-slot-class)
	(push (slot-value dslotd 'my-direct-info)
	      my-direct-info-list)))
    (let ((initargs (call-next-method)))
      (if my-direct-info-list
	  (list* 'my-effective-info my-direct-info-list initargs)
	  initargs))))

(defmethod effective-slot-definition-class ((class my-class) initargs)
  (find-class (if (getf 'my-effective-info initargs)
                  'my-effective-slot-class
	          'standard-effective-slot-definition)))
----------------
Richard Harris
Technical Details
Message-ID: <9105032201.AA13370@cs.rpi.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!tut.cis.ohio-state.edu!unreplyable!garbage

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!tut.cis.ohio-state.edu!unreplyable!garbage
From: harrisr@cs.rpi.edu (Richard Harris)
Newsgroups: comp.lang.clos
Subject: Controlling the class of effective-slot-definition objects
Message-ID: <9105032201.AA13370@cs.rpi.edu>
Date: 3 May 91 22:01:41 GMT
Sender: welch@tut.cis.ohio-state.edu
Distribution: inet
Organization: CommonLoops
Lines: 56