Product SiteDocumentation Site

4.2.6. Defining an UNKNOWN Method

When an object that receives a message does not have a matching message name, the language processor checks if the object has a method named UNKNOWN. If the object has an UNKNOWN method, the language processor calls UNKNOWN, passing two arguments. The first argument is the name of the method that was not located. The second argument is an array containing the arguments passed with the original message.
For example, the following UNKNOWN method will print out the name of the invoked method and then invoke the same method on another object. This can be used track the messages that are sent to an object:

Example 4.9. Defining an UNKNOWN method


::method unknown
expose target      -- will receive all of the messages
use arg name, arguments
say name "invoked with" arguments~toString
-- send along the message with the original args
forward to(target) message(name) arguments(arguments)