- Documentation
- Reference manual
- Modules
- Why Use Modules?
- Defining a Module
- Importing Predicates into a Module
- Controlled autoloading for modules
- Defining a meta-predicate
- Overruling Module Boundaries
- Interacting with modules from the top level
- Composing modules from other modules
- Operators and modules
- Dynamic importing using import modules
- Reserved Modules and using theāuser' module
- An alternative import/export interface
- Dynamic Modules
- Transparent predicates: definition and context module
- Module properties
- Compatibility of the Module System
- Modules
- Packages
- Reference manual
6.9 Operators and modules
Operators (section 4.25)
are local to modules, where the initial table behaves as if it is copied
from the module user
(see
section 6.11). A
specific operator can be disabled inside a module using :- op(0,
Type, Name)
. Inheritance from the public table can be restored
using :- op(-1, Type, Name)
.
In addition to using the op/3
directive, operators can be declared in the module/2
directive as shown below. Such operator declarations are visible inside
the module, and importing such a module makes the operators visible in
the target module. Exporting operators is typically used by modules that
implement sub-languages such as chr (see
chapter 9). The example below
is copied from the library
library(clpfd)
.
:- module(clpfd, [ op(760, yfx, #<==>), op(750, xfy, #==>), op(750, yfx, #<==), op(740, yfx, #\/), ... (#<==>)/2, (#==>)/2, (#<==)/2, (#\/)/2, ... ]).