B.6 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.

The library(http_load) provides an example, loading Prolog sources directly from an HTTP server.

prolog:comment_hook(+Comments, +Pos, +Term)
This hook allows for processing ---structured--- comments encountered by the compiler. The reader collects all comments found from the current position to the end of the next term. It calls this hook providing a list of Position-Comment in Comments, the start-position of the next term in Pos and the next term itself in Term. All positions are stream-position terms. This hook is exploited by the documentation system. See stream_position_data/3. See also read_term/3.