|Did you know ...||Search Documentation:|
|operators.pl -- Manage operators|
Often, one wants to define operators to improve the readibility of some very specific code. Operators in Prolog are global objects and changing operators changes syntax and possible semantics of existing sources. For this reason it is desirable to reset operator declarations after the code that needs them has been read. This module defines a rather cruel -but portable- method to do this.
:- push_operators( [ op(900, fx, hello_world) , op(600, xf, *) ]). hello_world World :- .... :- pop_operators.
While the above are for source-code, the calls push_operators/2 and pop_operators/1 can be used for local processing where it is more comfortable to carry the undo context around.
NOTE: In recent versions of SWI-Prolog operators are local to a module and can be exported using the syntax below. This is not portable, but otherwise a more structured approach for operator handling.
:- module(mymodule, [ mypred/1, op(500, fx, myop) ]).