| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (6 out of 12)

Creating Method Declarations

For every operation that you want to implement using methods, you must create a definition called a method-declaration. This definition declares the name of the operation: every method that implements it for a particular class has this name.

In the vessel example, you would need one method declaration to define the fill operation. This declaration would suffice for all fill methods on all classes, no matter how numerous the methods, or how the class hierarchy might be structured or restructured. If you also needed to implement an empty operation, you would need a second method declaration to define it; and so on for any number of operations.

To create a method declaration:

  1. Select KB Workspace > New Definition > procedure > method-declaration

  2. Open the method declaration's table.

  3. Edit the Names attribute to specify the name of the operation. You can use any available name.

For example, the following method declaration defines the fill operation used in the vessel example:


A method declaration can exist on any workspace. However, you can keep track of method declarations more easily if you store them systematically. One possibility is to keep them all on a workspace dedicated to that purpose. Another is to store each on the subworkspace of the highest-level class that uses the method.


Note: If you give a method declaration and a procedure the same name, and use that name in a call statement or a start action, you cannot predict whether G2 will invoke a method or the procedure. Avoid using the same name for both a method declaration and a procedure.

Flagging Call Next Method Requirements

Method declarations have one class-specific attribute:

Attribute Description
Requires-call-next-method?
Flags developers that any method based on this method-declaration must include a call next method statement in order to function correctly.
Allowable values:
yes, no
Default value:
no

G2 does not enforce the restriction implied by Requires-call-next-method?. The attribute is strictly informational, and has no effect on method compilation or KB execution.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (6 out of 12)

Copyright © 1997 Gensym Corporation, Inc.