Previous: , Up: Abstract Objects   [Contents][Index]


14.5.6.2 Object-Oriented Methods

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

The @defop command is the general definition command for these method-like entities.

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 method named expose; we would say that this window system defines an 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

The @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 argumentsbody-of-definition
@end defop

@defop creates an entry, such as ‘expose on windows’, in the index of functions.

@deftypeop category class data-type name arguments

The @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

The @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 subclasses.

@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.

For example:

@defmethod bar-class bar-method argument
…
@end defmethod

illustrates the definition for a method called bar-method of the class bar-class. The method takes an argument.

@defmethod creates an entry in the index of functions.

@deftypemethod class data-type name arguments

The @deftypemethod command is the definition command for methods in object-oriented typed languages, such as C++ and Java. It is similar to the @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 @deftypefnnewline option (see Functions in Typed Languages).


Previous: , Up: Abstract Objects   [Contents][Index]