DEFCLASS slot options in CAPI:DEFINE-INTERFACE
Has anyone noticed that the :DOCUMENTATION slot-option, if provided in
a define-interface form for a slot defined within :panes (and
:layouts, &c., but I haven't checked these cases), doesn't get put
into the slot definition of the corresponding DEFCLASS form. E.g., in
the following DEFINE-INTERFACE, the :reader, :writer, and :accessor
are present in the macroexpansion's DEFCLASS.
It make sense that the allocation, initarg, initform and type aren't
passed through, since the allocation should always be instance (so
that the same pane isn't displayed in multiple interfaces), the
initarg wouldn't be used, initform isn't useful since the
capi::initialize-instance method creates an instance of the pane, and
the type is already known from the define-interface form. But I don't
see a reason not to pass the :documentation option through to the
defclass.
(capi:define-interface interface-class () ()
(:panes
(output capi:output-pane
:reader reader
:writer writer
:accessor accessor
:allocation allocation ; * shouldn't be passed through
:initarg initarg ; * no reason to pass through
:initform initform ; * no reason to pass through
:type type ; * already known
:documentation "docstring")))
expands to
(DSPEC:DEF (CAPI:DEFINE-INTERFACE INTERFACE-CLASS)
(DEFCLASS INTERFACE-CLASS
(CAPI:INTERFACE)
((OUTPUT :READER READER :WRITER WRITER :ACCESSOR ACCESSOR))
(:METACLASS CAPI::CAPI-CLASS))
NIL
NIL
(DEFMETHOD CAPI::INITIALIZE-INTERFACE
:AFTER
((#:SELF465245 INTERFACE-CLASS) &REST #:ARGS465246 &KEY &ALLOW-OTHER-KEYS)
(WITH-SLOTS (OUTPUT) #:SELF465245
(DECLARE (IGNORABLE OUTPUT))
(LET ((CAPI::SELF #:SELF465245) (CAPI:INTERFACE #:SELF465245))
(DECLARE (IGNORABLE CAPI::SELF CAPI:INTERFACE))
(SETF (SLOT-VALUE #:SELF465245 'OUTPUT)
(MAKE-INSTANCE 'CAPI:OUTPUT-PANE
:ALLOCATION
ALLOCATION
:INITARG
INITARG
:INITFORM
INITFORM
:TYPE
TYPE
:DOCUMENTATION ; should be up in the defclass form
"docstring"
:NAME
'OUTPUT))
(SETF (SLOT-VALUE #:SELF465245 'CAPI::PANES)
(LIST* (SLOT-VALUE #:SELF465245 'OUTPUT)
(SLOT-VALUE #:SELF465245 'CAPI::PANES))))))
'INTERFACE-CLASS)
As a workaround, I do
(capi:define-interface interface-class () ()
(:panes
(output capi:output-pane
#-(and) :documentation #-(and) "docstring")))
since it really is nice to have a docstring with the slot definition,
to have it look like a docstring in the source rather than a comment,
and since the documentation shouldn't be an initarg to the pane. (In
my syntax highlighting, strings (including docstrings) are green, but
comments are red, so the difference really is noticeable.) While I
don't think LW does anything with slot docstrings, some documentation
generators know about them, and that's another reason that it would be
nice to have define-interface recognize the :documentation
option---the documentation generators can macroexpand to see the
defclass form and read the documentation.
Anyone else run into this?
--
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/