4.11.9 Creating a Module Dynamically

There are several ways in which you can create a module without loading a module-file for it. One way to do this is by asserting clauses into a specified module. For example, the command (A) will create the dynamic predicate f/1 and the module m if they did not previously exist.

     | ?- assert(m:f(x)). (A)

Another way to create a module dynamically is to compile a non-module-file into a specified module. For example (B), will compile the clauses in File into the module M.

     | ?- compile(M:File). (B)

The same effect can be achieved by (temporarily) changing the type-in module to M (see ref-mod-tyi) and then calling compile(File), or executing the command in module M as in (C).

     | ?- M:compile(File). (C)

Send feedback on this subject.