15: Declaring Operations

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

TS Ref - 26 JUN 1996

Generated by the sweat of Mike Boom's brow.