next up previous contents
Next: Semantics Up: The Extended CHR Implementation Previous: Syntactic Differences

Compiling

After loading the extended chr library, programs containing CHR code can be compiled directly. Thus, CHR code can be freely mixed with normal Prolog code in any file. In particular, a compilation may now compile code from different files in different modules which may all contain CHR codes. This was not a problem with the old library because CHR code had to be compile separately.

In the extended library, CHR code can occur anywhere in a particular module, and for each module, all the CHR code (which may reside in different files) will all be compiled into one unit (handler declarations are ignored by the system, they are present for compatibility purposes only), with the same constraint store. CHR code in different modules are entirely separate and independent from each other.

In order to allow CHR code to occur anywhere inside a module, and also because it is difficult to define a meaning for replacing multi-heads rules, compilation of CHR code is always incremental, i.e. any existing CHR code in a module is not replaced by a new compilation. Instead, the rules from the new compilation is added to the old ones.

It is possible to clear out old CHR code before compiling a file. This is done with the chr/1 predicate. This first remove any existing CHR code in any module before the compilation starts. It thus approximates the semantics of chr/1 of the old library, but no Prolog file is generated.



Joachim Schimpf
Sun Jul 19 22:34:17 BST 1998