SWI-Prolog 7.3.6 Reference Manual: Section B.8

## B.8 Hooks for loading files

All loading of source files is achieved by load_files/2. The hook prolog_load_file/2 can be used to load Prolog code from non-files or even load entirely different information, such as foreign files.

prolog_load_file(+Spec, +Options)
  Load a single object. If this call succeeds, load_files/2 assumes the action has been taken care of. This hook is only called if Options does not contain the `stream(Input)` option. The hook must be defined in the module `user`.

  This can be used to load from unusual places. For example, library `library(http/http_load)` loads Prolog directly from an HTTP server. It can also be used to load source in unusual forms, such as loading compressed files without decompressing them first. There is currently no example of that.

prolog:comment_hook(+Comments, +Pos, +Term)
  This hook allows for processing comments encountered by the compiler. If this hook is defined, the compiler calls read_term/2 with the option `comments(Comments)`. If the list of comments returned by read_term/2 is not empty it calls this comment hook with the following arguments.

  - Comments is the non-empty list of comments. Each comment is a pair Position-String, where String is a string object (see section 5.2) that contains the comment including delimiters. Consecutive line comments are returned as a single comment.
  - Pos is a stream-position term that describes the starting position of Term
  - Term is the term read.

  This hook is exploited by the documentation system. See stream_position_data/3. See also read_term/3.