Modules as blobs

Author(s): Isabel Garcia-Contreras, Jose F. Morales.

This module implements (temporary) modules-as-blobs facilities. They allow the runtime creation of modules from strings and terms.


Run-time creation of modules is currently implemented by writing the module code into a unique temporary directory (using the system mktemp_in_tmp/2 predicate).

Currently they need to be deleted explicitly.

Note that this is a temporary solution before read/write stream operations can be work on in-memory objects.


The predicate new_modblob/4 creates a new temporary module, that can be deleted with delete_modblob/1.

Module creation requires the module name, export list, program clauses, and returns the module object (currently a path). If a module directive is specified, the export list is ignored.


?- new_modblob([(p(A) :- q(A)), (q(b))], [p/1], my_tmp_mod, ModBlob), modblob_path(ModBlob, Path).
Path = '/tmp/tmp_modsfbMY9Y/' ?

where the contents of /tmp/tmp_modsfbMY9Y/ are:

p(A) :-

Usage and interface

Documentation on exports



Write clauses Clauses in a temporary module identified by ModBlob.


Removes the data associated to ModBlob

  • The following properties should hold at call time:
    (modblobs:modblob/1)ModBlob is a is a temporary module object
  • The following properties should hold globally:
    (native_props:is_det/1)All calls of the form delete_modblob(ModBlob) are deterministic.


Obtain the temporary file associated to ModBlob

  • The following properties should hold at call time:
    (basic_props:atm/1)ModBlob is an atom.
  • The following properties should hold upon exit:
    (basic_props:atm/1)ModPath is an atom.

Documentation on imports

This module has the following direct dependencies: