Article View: comp.lang.clos
Article #569Re: Best way to set class slots
From: Harley Davis
Date: Fri, 18 Dec 1992 09:37
Date: Fri, 18 Dec 1992 09:37
40 lines
1769 bytes
1769 bytes
In article <23063@venera.isi.edu> tar@ISI.EDU (Thomas A. Russ) writes:
I was wondering what the best way to set a slot with allocation :class
is. In particular, I wonder if there is any way to do this portably
without creating an instance of the class.
Initially I thought that using the CLASS-PROTOTYPE from the MOP would
be a good solution, but the documentation indicates that setting slots
on the prototype is a no-no.
Currently I just make an instance, set the slot and then throw the
instance away. This just strikes me as wasteful.
Any better ideas?
If you want to set a slot given the class but without an instance,
perhaps what you really want is a class slot -- ie, a new metaclass
with an additional slot.
(defclass my-class (standard-class)
((new-slot :initform ...
:accessor my-class-new-slot)))
Then your application classes specify my-class as their metaclass:
(defclass app-object ()
(...)
:metaclass my-class)
It depends on the semantics of the slot in question.
-- Harley Davis
--
------------------------------------------------------------------------------
nom: Harley Davis ILOG S.A.
net: davis@ilog.fr 2 Avenue Gallie'ni, BP 85
tel: (33 1) 46 63 66 66 94253 Gentilly Cedex, France
Technical Details
Message-ID:
<DAVIS.92Dec18103711@passy.ilog.fr>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!julienas!corton!ilog!davisReferences:
<23063@venera.isi.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!julienas!corton!ilog!davis From: davis@passy.ilog.fr (Harley Davis) Newsgroups: comp.lang.clos Subject: Re: Best way to set class slots Message-ID: <DAVIS.92Dec18103711@passy.ilog.fr> Date: 18 Dec 92 09:37:11 GMT References: <23063@venera.isi.edu> Sender: news@ilog.fr Distribution: comp Organization: ILOG S.A., Gentilly, France Lines: 40 In-reply-to: tar@ISI.EDU's message of 16 Dec 92 00:19:37 GMT