This section describes the constraint attributes that can be associated with deftemplates and defclasses so that type checking can be performed on slot values when template facts and instances are created. The constraint information is also analyzed for the patterns on the LHS of a rule to determine if the specified constraints prevent the rule from ever firing.
Two types of constraint checking are supported: static and dynamic. When static constraint checking is enabled, constraint violations are checked when function calls and constructs are parsed. This includes constraint checking between patterns on the LHS of a rule when variables are used in more than one slot. When dynamic constraint checking is enabled, newly created data objects (such as deftemplate facts and instances) have their slot values checked for constraint violations. Essentially, static constraint checking occurs when a CLIPS program is loaded and dynamic constraint checking occurs when a CLIPS program is running. By default, static constraint checking is enabled and dynamic constraint checking is disabled. The default behavior can be changed by using the set-static-constraint-checking and set-dynamic-constraint-checking functions.
Unless dynamic constraint checking is enabled, constraint information associated with constructs is not saved when a binary image is created using the bsave command.
The general syntax for constraint attributes is shown following.
Syntax
<constraint-attribute> ::= <type-attribute>| <allowed-constant-attribute> | <range-attribute> | <cardinality-attribute>