Product SiteDocumentation Site

4.2.5. Default Search Order for Method Selection

The search order for a method name matching the message is for:
  1. A method the object itself defines with SETMETHOD or ENHANCED. (See Section 5.1.1.21, “setMethod” .)
  2. A method the object's class defines. (Note that an object acquires the instance methods of the class to which it belongs at the time of its creation. If a class gains additional methods, objects created before the definition of these methods do not acquire these methods.)
  3. A method that a superclass of the object's class defines. This is also limited to methods that were available when the object was created. The order of the INHERIT (see Section 5.1.2.9, “inherit”) messages sent to an object's class determines the search order of the superclass method definitions.
This search order places methods of a class before methods of its superclasses so that a class can supplement or override inherited methods.
If the language processor does not find a match for the message name, the language processor checks the object for a method name UNKNOWN. If it exists, the language processor calls the UNKNOWN method and returns as the message result any result the UNKNOWN method returns. The UNKNOWN method arguments are the original message name and a Rexx array containing the original message arguments.
If the object does not have an UNKNOWN method, the language processor raises a NOMETHOD condition. If there are no active traps for the NOMETHOD condition, a syntax error is raised.