What's the most appropriate supported method for determining the slots
of a class ?
I tried the following as an example:
(defclass myclass ()
((name :initform "" :accessor name)
(description :initform "" :accessor description)))
(setf mi (make-instance 'myclass))
(setf mc (class-of mi))
(slot-value mc 'clos::slots)
...this gave me a list of some slots. Is there some other more
appropriate accepted method of doing this ? What do you pros use ?
What is the best book that describes meta-model work with CLOS ?
Any help would be appreciated. Thanks.
In article <·············@erols.com>, ········@erols.com wrote:
> What's the most appropriate supported method for determining the slots
> of a class ?
>
>
> I tried the following as an example:
>
> (defclass myclass ()
> ((name :initform "" :accessor name)
> (description :initform "" :accessor description)))
>
> (setf mi (make-instance 'myclass))
> (setf mc (class-of mi))
> (slot-value mc 'clos::slots)
>
> ...this gave me a list of some slots. Is there some other more
> appropriate accepted method of doing this ? What do you pros use ?
>
> What is the best book that describes meta-model work with CLOS ?
>
> Any help would be appreciated. Thanks.
Depends on your Lisp. For Lisps that support the MOP, see:
http://www.elwoodcorp.com/alu/mop/dictionary.html#class-mo-readers
Otherwise your vendors documentation might some help.
MCL for example has:
class-direct-class-slots
class-direct-instance-slots
class-class-slots
class-instance-slots
--
http://www.lavielle.com/~joswig
······@lavielle.com (Rainer Joswig) writes:
> Depends on your Lisp. For Lisps that support the MOP, see:
the mop way to do get the class slot names of a class is to use class-slots
and slot-definition-name:
(defun slot-names-of-class (object)
(mapcar #'clos:slot-definition-name
(clos:class-slots (class-of object))))
> Otherwise your vendors documentation might some help.
> MCL for example has:
MCL could really need some MOP support, I especially miss ensure-class
(yes, is easy to simulate (a subset of?) it by using ccl-internal
functions, but that's not very maintainable code)
--
espen
In article <··············@gromit.nextel.no>, Espen Vestre <··@nextel.no> wrote:
> > Otherwise your vendors documentation might some help.
> > MCL for example has:
>
> MCL could really need some MOP support, I especially miss ensure-class
> (yes, is easy to simulate (a subset of?) it by using ccl-internal
> functions, but that's not very maintainable code)
The problem is also that some Lisps have a CLOS package where
the MOP stuff is defined. This is not portable, too.
MCL for example has no CLOS package.
MCL also could use real slot description meta objects,
SLOT-VALUE-USING-CLASS, ...
--
http://www.lavielle.com/~joswig
From: Dave Hallman
Subject: Re: How to get class slots ?
Date:
Message-ID: <362E3F21.521C@erols.com>
Dave Hallman wrote:
>
> What's the most appropriate supported method for determining the slots
> of a class ?
>
> I tried the following as an example:
>
> (defclass myclass ()
> ((name :initform "" :accessor name)
> (description :initform "" :accessor description)))
>
> (setf mi (make-instance 'myclass))
> (setf mc (class-of mi))
> (slot-value mc 'clos::slots)
>
> ...this gave me a list of some slots. Is there some other more
> appropriate accepted method of doing this ? What do you pros use ?
>
> What is the best book that describes meta-model work with CLOS ?
>
> Any help would be appreciated. Thanks.
Thanks for the above responses. I don't know too much about CLOS
standards. If someone says they are ANSI CLOS compliant, does that
mean that they support MOP (Meta-Object Protocol) ?
In article <·············@erols.com>, ········@erols.com wrote:
> > What is the best book that describes meta-model work with CLOS ?
"The Art of the Metaobject Protocol".
See: http://www.elwoodcorp.com/alu/mop/index.html
> >
> > Any help would be appreciated. Thanks.
>
> Thanks for the above responses. I don't know too much about CLOS
> standards. If someone says they are ANSI CLOS compliant, does that
> mean that they support MOP (Meta-Object Protocol) ?
Yes. ANSI CL does not say much about meta objects, etc.
There is an informal standard by following what
the above book describes. Not all Common Lisp implementation
implement it.
--
http://www.lavielle.com/~joswig