From: Mirko
Subject: accessing a slot documentation
Date: 
Message-ID: <7e34a440-9ebc-4d4c-a0f8-80c96e9863ee@x38g2000yqj.googlegroups.com>
Hello,

I found two posts on accessing documentation of all slots.  The idea
is as follows (on sbcl here):

> (defclass foo ()
    ((x :documentation "Yer X")
     (y :documentation "Yer Y")))

> (mapcar (lambda (s)
              (documentation s t))
           (sb-mop:class-direct-slots (find-class 'foo)))
("Yer X" "Yer Y")

How can I get the documentation of slot X only?  Do I need to parse
the outputs of  (sb-mop:class-direct-slots (find-class 'foo)) ?
> (sb-mop:class-direct-slots (find-class 'foo))
(#<SB-MOP:STANDARD-DIRECT-SLOT-DEFINITION X>
 #<SB-MOP:STANDARD-DIRECT-SLOT-DEFINITION Y>)
or can I access the slot definition in some way (like slot-value, but
more encompassing)?

Thank you,

Mirko

From: Pascal J. Bourguignon
Subject: Re: accessing a slot documentation
Date: 
Message-ID: <7cprgwm292.fsf@pbourguignon.anevia.com>
Mirko <·············@gmail.com> writes:

> Hello,
>
> I found two posts on accessing documentation of all slots.  The idea
> is as follows (on sbcl here):
>
>> (defclass foo ()
>     ((x :documentation "Yer X")
>      (y :documentation "Yer Y")))
>
>> (mapcar (lambda (s)
>               (documentation s t))
>            (sb-mop:class-direct-slots (find-class 'foo)))
> ("Yer X" "Yer Y")
>
> How can I get the documentation of slot X only?  Do I need to parse
> the outputs of  (sb-mop:class-direct-slots (find-class 'foo)) ?
Yes. Instead of mapcar, use find:

(documentation
  (find 'x (mop:class-direct-slots (find-class 'foo))
          :key (function mop:SLOT-DEFINITION-NAME)) t)

> or can I access the slot definition in some way (like slot-value, but
> more encompassing)?

Why do you ask me?  How would I know?  I'd do: (apropos "SLOT" "MOP")
and see not better than you could, that indeed there is no accessor
returning directly the slot-definition by name.

-- 
__Pascal Bourguignon__
From: budden
Subject: Re: accessing a slot documentation
Date: 
Message-ID: <e3d5a24d-a52e-450f-aad8-b44ab99b4bea@b16g2000yqb.googlegroups.com>
Hallo Mirko!
  If you're in SLIME, try M-x slime-inspect <press Return> (sb-
mop:class-direct-slots (find-class 'foo))

You'll get a screen of slot information, including name of the slot
and its documentation. So, SLIME knows how to get it.
Then you can trace/read SLIME/slime-mode sources to learn how this
information is recovered from SBCL.

I guess this will not be portable unless you use SLIME's functions
(which provide a cross-implementation compatibility layer).

Good luck!
From: Mirko
Subject: Re: accessing a slot documentation
Date: 
Message-ID: <26b296e2-8b94-46a6-a334-a7c227f32348@o36g2000yqh.googlegroups.com>
On Mar 6, 3:22 am, budden <···········@mail.ru> wrote:
> Hallo Mirko!
>   If you're in SLIME, try M-x slime-inspect <press Return> (sb-
> mop:class-direct-slots (find-class 'foo))
>
> You'll get a screen of slot information, including name of the slot
> and its documentation. So, SLIME knows how to get it.
> Then you can trace/read SLIME/slime-mode sources to learn how this
> information is recovered from SBCL.
>
> I guess this will not be portable unless you use SLIME's functions
> (which provide a cross-implementation compatibility layer).
>
> Good luck!

Thanks Budden.

I do use SLIME and the inspector, but in this particular instance I
needed access to the documentation from with CL code.  So, I will use
Pascal's suggesions (including the `apropos' one, I always forget
about it).

(BTW, thanks Pascal)

Mirko