Node:CHR Backward Compatibility, Previous:CHR Constraint Handlers, Up:CHR

Backward Compatibility

In this section, we discuss backward compatibility with the CHR library of Eclipse Prolog.

  1. The restriction on at most two heads in a rule has been abandoned. A rule can have as many heads as you like. Note however, that searching for partner constraints can be expensive.
  2. By default, rules are compiled in textual order. This gives the programmer more control over the constraint handling process. In the Eclipse library of CHR, the compiler was optimizing the order of rules. Therefore, when porting a handler, rules may have to be reordered. A good heuristic is to prefer simplification to simpagation and propagation and to prefer rules with single heads to rules with several heads. Instead of manually rearranging an old handler one may also use the following combination of options to get the corresponding effect:
  3. For backward compatibility, the already_in_store, already_in_head and guard_bindings options are still around, but there are CHR syntax extensions (see CHR Syntax) and pragmas (see CHR Pragmas) offering better grained control.
  4. The Eclipse library of CHR provided automatic built-in labeling through the label_with declaration. Since it was not widely used and can be easily simulated, built-in labeling was dropped. The same effect can be achieved by replacing the declaration label_with Constraint if Guard by the simplification rule chr_labeling, Constraint <=> Guard | Constraint', chr_labeling and by renaming the head in each clause Constraint :- Body into Constraint' :- Body where Constraint' is a new predicate. Efficiency can be improved by declaring Constraint to be passive: chr_labeling, Constraint#Id <=> Guard | Constraint', chr_labeling pragma passive(Id). This translation will not work if option(already_in_heads,on). In that case use e.g. chr_labeling(_), Constraint <=> Guard | Constraint', chr_labeling(_) to make the new call to chr_labeling differ from the head occurrence.
  5. The set of built-in predicates for advanced CHR users is now larger and better designed. Also the debugger has been improved. The Opium debugging environment is not available in SICStus Prolog.