All Manuals > KnowledgeWorks and Prolog User Guide > 7 Reference Guide

deftactic Macro

Summary

Defines a tactic function for use in context strategies.

Package

kw

Signature

deftactic tactic-name type lambda-list &body body => tactic-name

Arguments
tactic-name
A symbol.
type
Either :static or :dynamic.
lambda-list
A two argument lambda list.
body
A function body.
Values
tactic-name
A symbol.
Description

The macro deftactic defines a new conflict resolution tactic named tactic-name.

type is the type of the tactic, which may be :static if body does not look into the slots of the objects making up the instantiation, otherwise :dynamic.

lambda-list specifies two variable, which will be bound to two instantiation objects and when the forms of body are evaluated. body should return non-nil if and only if the first instantiation object is preferred to the second.

deftactic also defines a function named tactic-name and body can be preceded by a documentation string.

The newly defined tactic may be used as any in-built tactic.

Examples
(deftactic prefer-trucks :static (inst1 inst2)
  (flet ((truck-p (obj) (typep obj 'truck)))
    (and (some #'truck-p (inst-token inst1))
      (notany #'truck-p (inst-token inst2)))))

The new tactic may be used in a defcontext form:

(defcontext my-context :strategy (prefer-trucks))
See also

inst-bindings
inst-token
inst-rulename
defcontext


KnowledgeWorks and Prolog User Guide (Windows version) - 01 Dec 2021 19:36:03