[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page
Top Document: FAQ: Object-oriented Programming in Lisp 5/7 [Monthly posting]
Previous Document: [5-4] How can I store data and CLOS instances (with possibly circular references) on disk so that they may be
Next Document: [5-6] Free CLOS software.
-
Search the FAQ Archives
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page
Top Document: FAQ: Object-oriented Programming in Lisp 5/7 [Monthly posting]
Previous Document: [5-4] How can I store data and CLOS instances (with possibly circular references) on disk so that they may be
Next Document: [5-6] Free CLOS software.
[5-5] Given the name of a class, how can I get the names of its slots?
(defun class-slot-names (class-name)
"Given a CLASS-NAME, returns a list of the slots in the class."
(mapcar #'clos:slot-definition-name
(clos:class-slots (find-class class-name))))
(defmethod class-slot-names ((instance standard-object))
"Given an INSTANCE, returns a list of the slots in the instance's class."
(mapcar #'clos:slot-definition-name
(clos:class-slots (class-of instance))))
You can use CLASS-DIRECT-SLOTS instead of CLASS-SLOTS if you don't
want inherited slots. Note that these functions are from the
meta-object protocol specified in the original X3J13 draft spec
(document X3J13/88-003), and may not be supported by all Lisps.
Top Document: FAQ: Object-oriented Programming in Lisp 5/7 [Monthly posting]
Previous Document: [5-4] How can I store data and CLOS instances (with possibly circular references) on disk so that they may be
Next Document: [5-6] Free CLOS software.
Part1 - Part2 - Part3 - Part4 - Part5 - Part6 - Part7 - Single Page
[ Usenet FAQs | Search | Web FAQs | Documents | RFC Index ]
Send corrections/additions to the FAQ Maintainer:
ai+lisp-faq@cs.cmu.edu
Last Update July 20 2008 @ 00:12 AM