Mitch <········@bermita.com> writes:
> Is there a way to obtain a list of all the slots in a class?
As with the MOP's CLASS-DIRECT-SLOTS and CLASS-SLOTS?
<http://www.lisp.org/mop/dictionary.html>
---Vassil.
--
Bound variables, free programmers.
Pascal Bourguignon was kind enough to show me this:
> Personally, I would be most interested in seeing how to iterate through
> each slot without having to know the slot names a priori.
[211]> (asdf:oos 'asdf:load-op :closer-mop)
...
[212]> (defclass c1 () (a b))
#1=#<STANDARD-CLASS C1>
[213]> (defclass c2 (c1) (d e f))
#1=#<STANDARD-CLASS C2>
[214]> (closer-mop:compute-slots (find-class 'c2))
(#<CLOS:STANDARD-EFFECTIVE-SLOT-DEFINITION A #x2052E666>
#<CLOS:STANDARD-EFFECTIVE-SLOT-DEFINITION B #x2052E6A6>
#<CLOS:STANDARD-EFFECTIVE-SLOT-DEFINITION D #x2052E6E6>
#<CLOS:STANDARD-EFFECTIVE-SLOT-DEFINITION E #x2052E726>
#<CLOS:STANDARD-EFFECTIVE-SLOT-DEFINITION F #x2052E766>)
[217]> (dolist (slot (closer-mop:compute-slots (find-class 'c2)))
(print (closer-mop:slot-definition-name slot)))
A
B
D
E
F
NIL
Mitch wrote:
> Is there a way to obtain a list of all the slots in a class?
Meta-help: (apropos "-SLOTS") or (apropos "CLASS"), where the string is
a chance to apply your googleskill at guessing at subsequences that will
reveal what you seek.
kt
--
http://www.theoryyalgebra.com/
"In the morning, hear the Way;
in the evening, die content!"
-- Confucius