These commands allow you to define different sorts of function-like entities resembling methods in object-oriented programming languages. These entities take arguments, as functions do, but are associated with particular classes of objects.
@defop category class name arguments…¶
@defop command is the definition command for these
method-like entities with simple arguments.
For example, some systems have constructs called wrappers that
are associated with classes as methods are, but that act more like
macros than like functions. You could use
@defop Wrapper to
describe one of these.
Sometimes it is useful to distinguish methods and operations.
You can think of an operation as the specification for a method.
Thus, a window system might specify that all window classes have a
expose; we would say that this window system
expose operation on windows in general. Typically,
the operation has a name and also specifies the pattern of arguments;
all methods that implement the operation must accept the same
arguments, since applications that use the operation do so without
knowing which method will implement it.
Often it makes more sense to document operations than methods. For
example, window application developers need to know about the
expose operation, but need not be concerned with whether a
given class of windows has its own method to implement this operation.
To describe this operation, you would write:
@defop Operation windows expose
@defop command is written at the beginning of a line and
is followed on the same line by the overall name of the category of
operation, the name of the class of the operation, the name of the
operation, and its arguments, if any.
@defop creates an entry, such as ‘
windows’, in the index of functions.
@deftypeop category class data-type name arguments…¶
@deftypeop command is the generic definition command for
operations in object-oriented programming. It is particularly suitable
for typed object-oriented languages. It is similar to
@defop with the addition of the data-type parameter to
specify information on the return value of the method, for example the
@defmethod class name arguments…¶
@defmethod command is the definition command for methods
in object-oriented programming. A method is a kind of function that
implements an operation for a particular class of objects and its
@defmethod is equivalent to ‘@defop Method …’.
The command is written at the beginning of a line and is followed by
the name of the class of the method, the name of the method, and its
arguments, if any.
bar-classbar-method argument ... @end defmethod
illustrates the definition for a method called
bar-class. The method takes an argument.
@defmethod creates an entry in the index of functions.
@deftypemethod class data-type name arguments…¶
@deftypemethod command is the definition command for methods
in object-oriented languages, in particular for typed languages
such as C++ and Java. It is similar to the
with the addition of the data-type parameter to specify information
on the return value of the method, for example the return type.
The commands with information on return values are affected by the
@deftypefnnewline option (see Functions
in Typed Languages).