Copyright © 1998, 2001 by Ian Horswill, see comment within this file.
rules macroProgrammers typically write girl code by defining signals in terms of other signals. This supports a "backward-chaining" style of programming where defines propositions in terms of necessary and sufficient conditions. In this case, the definitions of the propositions (their necessary and sufficient conditions) are explicit in the code, but their entailments (what you can infer from a proposition) are left implicit; to know the entailment of a proposition, you have to look at the code for all the other propositions to find where it's used.
It is often more convenient to specify a set of propositions in terms of their entailments rather than their definitions. The rules macro allows you to define a set of propositions and their entailments using a set of if/then rules like you would find in a production system. Girl then solves for their definitions at compile time.
(rules rule ...)(rule rule)(if signal-expression consequent)
(when signal-expression consequents ...)(unless signal-expression consequents ...)(let ((variable value declarations ...)
...)
rules ...)
(let* ((variable value declarations ...)
...)
rules ...)
(letrec ((variable value declarations ...)
...)
rules ...)The consequent of a rule may be:
let, let*, or letrec
forms containing rules)accumulate procedure.
Accumulators are signals that get their inputs from rules or from signals
that use the drives declaration.(proposition)or of its inputs.(set! register signal)(action args ...)active-when clause, etc.) enables it. Note that
this does make it hard to tell if the action is trying to stop
itself.The following signal procedures are also exported by the plans
package specifically for use as rule consequents:
(start! action args ...)(stop! action)start! or called from another plan; it cannot
override an active-when clause in the plan.In addition, the role-passing package exports start-indirect!
and stop-indirect!, which allow indirection through the role
binding mechanisms.
Note: The ruleset macro is now deprecated. Use rules
instead.
Rules are defined with the ruleset macro.
The rules within a ruleset expression can be any of the following forms: