15: Declaring Operations
- Creating an operation identifier
- The ID can be the same as operation IDs in other classes because the operation is local to the instance.
- One exception: If the ID is the same as the operation ID of the class's superclass, it will override the operation in the superclass
- You can provide more than one identifier for an operation.
- Each ID specifies a separate operation.
- All the operations defined this way are identical except for identification.
- You can redefine here an operation that exists under the same name in a superclass, but only under severe compatibility restraints.
- Declaring the status of an operation
- Declare an abstract op with the "abstract" keyword.
- An abstract op has no implementation in this class definition. Any non-abstract subclass must provide an implementation of this operation.
- Declare a sealed op with the "sealed" keyword so the operation can't be reimplemented in subclasses.
- Declare a sponsored op with the "sponsored" keyword.
- Defer discussion of sponsorship until the permits chapter in the Process section of this book.
- Creating an operation signature
- Input arguments
- Specifying type for argument input.
- Specifying passage of an argument
- By ref, copy, etc. Discussed in detail in a later chapter.
- Use an argument identifier to remove the argument from the argument stack for use within the method.
- You can provide multiple IDs with an argument; each ID creates a separate--but otherwise identical--argument
- The argument ID is normally used within the operation's method to work with or to store the argument.
- Forcing an argument to be an instance of a class, not simply a member
- Use "!"
- Specifying that an argument may also be nil
- Use "|Nil"
- Specifying a variable number of arguments at the end of the argument list
- Specifying type and passage
- The ellipsis literal
- Specifying arguments that aren't taken off the stack. (Don't name the argument.)
- Output result
- The output result is a single object (but it can be a complex object holding many other objects).
- Specifying type and passage
- Specifying exceptions thrown by the operation
- Using the "thrown" keyword
- Using exception identifiers
TS Ref - 26 JUN 1996
Generated by the sweat of Mike Boom's brow.