Article View: comp.lang.clos
Article #307Re: class variables
From: Jon L White
Date: Fri, 02 Oct 1992 16:26
Date: Fri, 02 Oct 1992 16:26
37 lines
1997 bytes
1997 bytes
Another approach to what are increasingly being called "per-class slots": -- set up a metaclass for such classes with this altered inheritance; for sake of discussion, call it PER-CLASS-SHARED-SLOTS-CLASS -- place a method on ENSURE-CLASS-USING-CLASS specialized to this metaclass (i.e. PER-CLASS-SHARED-SLOTS-CLASS) which snoops at the :direct-superclasses argument to collect the names of all the shared slots from all the supers which are of metaclass PER-CLASS-SHARED-SLOTS-CLASS. Then alter the :direct-slots argument to add canonicalized slot specifications for such shared slots (see CANONICALIZE-DIRECT-SLOT, which is also from AMOP), and then just CALL-NEXT-METHOD. The trick here is to utilize all the pre-existing machinery of an implementation's support for shared slots, but to fake-out the interface between DEFCLASS and the actual class creation protocol to make it look like every DEFCLASS form for the new metaclass actually had a :ALLOCATION :CLASS specification for any inherited shared slot. So here we are using the metaobject protocol to alter the inheritance behaviour within an (extended) metaclass. Refinement: figure out how to put the method on MAKE-INSTANCE, or on INITIALIZE-INSTANCE, instead of on ENSURE-CLASS-USING-CLASS. More refinement: figure out how to collate all the actual direct slot specifications from the set of all superclasses so as to resolve _each and every potential slot specification_ item in the automatically generated slot spec list. -- JonL --
Technical Details
Message-ID:
<9210021626.AA18097@kuwait.lucid>Path:
arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!lucid.com!jonl%kuwaitShow Full Headers
Complete Article Headers
Newsgroups: comp.lang.clos Path: arc1-ca.pugleaf.net!sparky!uunet!ukma!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!lucid.com!jonl%kuwait From: jonl%kuwait@lucid.com (Jon L White) Subject: Re: class variables Message-ID: <9210021626.AA18097@kuwait.lucid> Sender: daemon@cis.ohio-state.edu Organization: The Ohio State University Department of Computer and Information Science Date: Fri, 2 Oct 1992 16:26:52 GMT Lines: 37