Article View: comp.lang.clos
Article #19Re: Portability: Adding a slot to a class
From: Gary Hooyman
Date: Fri, 31 Jul 1992 08:35
Date: Fri, 31 Jul 1992 08:35
30 lines
2144 bytes
2144 bytes
nicholas writes
How can I add a slot to a class? One solution is to redefine class but that
isn't terribly portable since it requires having the source definition
of the class. P. 203 of the AMOP describes how a slot instance can be
created, e.g., (make-instance 'clos:standard-slot-definition ...).
Then, the question becomes how can a slot instance be added to a given class
as if it were (almost) a re-definition of the class? Can this be done
in a portable manner? If not, I'd be equally interested in an
implementation-specific solution for Lucid 4.0.2 on sparc.
I recently faced the same problem, and at first my solution was to
maintain protability and implement my own metainfo class. This class
had attributes that managed class name, slot names, etc and had methods
for redefining a class given a prototype instance using eval and quotes
that did not require any calls to metaobject protocol methods.
I have since reimplemented this to use MOP methods because:
Much of it is available in Lucid 4.02 (on DEC)
Implementation became cleaner because clos was managing
the metainformation so I didn't have to - my code was not
robust or general enough to do the job very well
MOP seems to be becomming standardized
(this I say only as an outsider looking in - it may or may
not be true, but it is my observation)
If you want to see any code examples, I can send them, but I
Technical Details
Message-ID:
<keSKjBC00iQQ0AHUcK@andrew.cmu.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!uakari.primate.wisc.edu!usenet.coe.montana.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!gh1h+References:
<1992Jul30.234218.28623@jpl-devvax.jpl.nasa.gov>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!elroy.jpl.nasa.gov!sdd.hp.com!uakari.primate.wisc.edu!usenet.coe.montana.edu!ogicse!das-news.harvard.edu!cantaloupe.srv.cs.cmu.edu!crabapple.srv.cs.cmu.edu!andrew.cmu.edu!gh1h+ From: gh1h+@andrew.cmu.edu (Gary Hooyman) Newsgroups: comp.lang.clos Subject: Re: Portability: Adding a slot to a class Message-ID: <keSKjBC00iQQ0AHUcK@andrew.cmu.edu> Date: 31 Jul 92 08:35:25 GMT References: <1992Jul30.234218.28623@jpl-devvax.jpl.nasa.gov> Organization: Masters student, Civil Engineering, Carnegie Mellon, Pittsburgh, PA Lines: 30 In-Reply-To: <1992Jul30.234218.28623@jpl-devvax.jpl.nasa.gov>