Probably a newbie question (since I am one!) but I can't think
where else to ask (or look)...
I'm having a little trouble with :documentation in the defclass
form (or more specifically, getting at the documentation once
a class is instantiated).
Basically, I define a doc string as follows:
(defclass my-class () ()
(:documentation "doc string"))
And instantiate it with:
(setf clinst (make-instance 'my-class))
Trying to see this documentation, I've tried the following:
(documentation clinst 'structure)
(documentation clinst 'structure-class)
(documentation clinst 'standard-class)
but all return NIL under CMUCL and a slightly more helpful
"Warning: Unspecialized DOCUMENTATION method called
with #<MY-CLASS 205FC38C> STANDARD-CLASS ." under LispWorks.
Does this mean I need to define a "documentation" method for
each class? I didn't realise documentation was a generic method.
If I *do* need a documentation method for the class, am I
correct in assuming that the usual "defmethod ..." form
is the right one to use?
Whilst we're on the subject, should I expect documentation to
be inherited by subclasses of my-class, or will each class
need it's own documentation string + documentation method?
Hopefully in a few weeks this will all be blindingly obvious
to me :>
-Duncan
>>>>> "Duncan" == Duncan Rose <ยทยท@robotcat.demon.co.uk> writes:
[snip]
Duncan> (defclass my-class () ()
Duncan> (:documentation "doc string"))
Duncan> Trying to see this documentation, I've tried the following:
Duncan> (documentation clinst 'structure)
Duncan> (documentation clinst 'structure-class)
Duncan> (documentation clinst 'standard-class)
Duncan> but all return NIL under CMUCL and a slightly more helpful
You didn't say which version of CMUCL older versions of CMUCL didn't
keep the doc-strings in classes around at all. This has been fixed in
CVS. You can get snapshots and other random releases from
www2.cons.org.
Ray
Duncan Rose wrote:
> (defclass my-class () () (:documentation "doc string"))
>
> And instantiate it with:
>
> (setf clinst (make-instance 'my-class))
>
> Trying to see this documentation, I've tried the following:
>
> (documentation clinst 'structure)
> (documentation clinst 'structure-class)
> (documentation clinst 'standard-class)
You want the documentation for the *class*, not for an instance
of the class. So maybe you should try:
(documentation (find-class 'my-class) t)
In Lispworks, this returns
"doc string"
as you would expect.
--
Arthur Lemmens
From: james anderson
Subject: Re: Documentation strings in defclass
Date:
Message-ID: <3F7D507E.B2012573@setf.de>
the documentation function has a more restrictive protocol that you are expecting
http://www.lispworks.com/reference/HyperSpec/Body/f_docume.htm
things like
(documentation 'my-class 'type)
or
(documentation (class-of clinst) 't)
should work better.
Duncan Rose wrote:
>
> ...
> but all return NIL under CMUCL and a slightly more helpful
> "Warning: Unspecialized DOCUMENTATION method called
> with #<MY-CLASS 205FC38C> STANDARD-CLASS ." under LispWorks.
>
as i read the description,
>
> Whilst we're on the subject, should I expect documentation to
> be inherited by subclasses of my-class, or will each class
> need it's own documentation string + documentation method?
>
i think the expectation would not be fulfilled.
...