Let's assume that X is the class of x. The way to install a method for the negation of an instance x of X is with a statement of the following form.
- X := x -> ...Here '...' represents the body of the function, consisting of suitable code for the operation at hand.
The method installed by the code above is automatically inherited by subclasses of X. Here is a brief description of the way this works. Suppose X is the parent of P. When an expression -p is to be evaluated, where the class of p is P, then the method for -P is applied, unless there isn't one, in which case the method for -X is applied, and so on, all the way up the chain of parents to the topmost ancestor of everything, which is called Thing.
As an extreme example of inheritance, the code
- Thing := x -> ...will install a method for negating anything, which will take effect as a last resort whenever more a specifically defined method isn't found.
The user may introduce new methods as well as new method names. So it is important to understand how methods are installed and consulted.
Applying a method named C to a thing x whose class is X means that
(lookup(C,X)) xis evaluated. In other words, C is used as a key to obtain a function from X (or its parent, grandparent, and so on), and the function is applied to x. See lookup .
Installing a method named C for the class X is done with code such as
X#C = (x) -> ...where '...' represents suitable code for the operation at hand.
Here is the routine for making new methods.
See also ., binary method, and classes.
Go to main index.
Go to concepts index.