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 general definition command for these
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.
The template is:
@defop category class name arguments… body-of-definition @end defop
@defop creates an entry, such as ‘
windows’, in the index of functions.
@deftypeop category class data-type name arguments…
@deftypeop command is the definition command for typed
operations in object-oriented programming. It is similar to
@defop with the addition of the data-type parameter to
specify the return type of the method.
@deftypeop creates an
entry in the index of functions.
@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 typed languages, such as C++ and Java. It is similar
@defmethod command with the addition of the
data-type parameter to specify the return type of the method.
@deftypemethod creates an entry in the index of functions.
The typed commands are affected by the
option (see Functions in Typed Languages).