A methodical object expression is the normal kind of object expression -- it defines the object behavior in terms of dispatching on an incoming message to select a method. User-E's function-definition, class-definition, lambda, for-loop, and when-catch constructs all use methodical object expressions in their expansion. Since E is not statically typed, the dispatch is based only on the message's verb (the message-name) and arity (number of arguments). Unlike Java class's definition, the methodical object expression allows the recipient to generically handle messages that fall through the dispatch, making it easy to write delegation patterns in E. In response to an incoming message, a methodical object (an instance of a methodical object expression) will first attempt to dispatch to a method with the same verb and arity as the message. If a match is not found among the methods explicitly coded in the eScript, the object will attempt to find a matching Miranda Method. If we find a matching method, then the message becomes the specimen the parameter patterns are to be matched against, and the method is executed. Else, if the eScript has a matcher, then the message becomes the specimen the matcher's pattern is to be matched against, and the matcher is executed. x |
||||||||||||||||||||||||
Unless stated otherwise, all text on this page which is either unattributed or by Mark S. Miller is hereby placed in the public domain.
|