defaction [Macro]
Purpose
The defaction macro defines or redefines an action. An action specifies a generic operation (analagous to a CLOS generic function) that is implemented by one or more Loom methods.
Syntax
defaction name parameters &key filters missing-methods
Arguments
The name argument is a non-nil symbol. The action has the same name as the methods that implement it. It cannot have the same name as an existing production.
The parameters argument contains zero or more formal parameters. Keyword parameters are supported, but optional and rest parameters are not. The action must have the same number of required and keyword parameters as the methods that implement it.
The filters argument is a keyword, or list of keywords, where each keyword identifies a filter. This series of filters specifies the strategy to be used for choosing among methods for the action. Candidate methods pass through each filter in the sequence, so that the number of surviving candidates is monotonically non-increasing. The filtering process continues as long as more than one method remains. Actions may use the following filters:
- The :overrides filter eliminates methods which have been declared to be less preferable than some other candidate method (see defmethod).
- The :most-specific filter eliminates any method whose situation pattern is specialized by some other candidate method's pattern.
- The :last-one filter selects the most-recently defined of the surviving candidate methods.
- The :select-one filter performs a pseudo-random selection of one of the candidate methods.
- The :select-all filter passes all of the surviving methods.
- The :warning filter passes a single surviving candidate method, or lists the surviving methods and warns that it cannot choose among them.
- The :error filter passes a single surviving candidate method, or lists the surviving methods and breaks.
If filters is not supplied, it defaults to (:most-specific :last-one).
The missing-method argument may be either :no-op, :warning, or :error. This argument specifies the action to be taken if no applicable method can be found. It defaults to :warning.
Value
The defined or redefined action is returned.
Remarks
If a method is defined before the corresponding action, Loom automatically creates that action.
Examples
(defaction test (x)) ==> |ACTION|TEST
(defaction pack (?obj &key ?fragile-p)) ==> |ACTION|PACK
(defaction move (?obj ?to)
:filters (:overrides :most-specific :last-one)
:missing-method :no-op) ==> |ACTION|MOVE
See Also
Last modified: Jun 1 1995