Tiny module with miscellaneous functions

Author(s): Arsen Kostenko.

This module holds just two predicates at the moment: write_pr/2 and read_pr. In both of them the '_pr' suffix is standing for 'predicate', which in turn means that both of them are intended for transportation of predicates from one environment to another.

Usage and interface

  • Library usage:
    :- use_module(library(dht_misc)).
  • Exports:
  • Other modules used:
    • System library modules:
      fastrw.

Documentation on exports

PREDICATE
write_pr/2 is a straight-forward wrapping around the fast_write/2 predicate, without any checks on arguments The sole purpose is to allow usage of various ways of writing to streams without changing entire code of DHT.

Usage: write_pr(Stream,Term)

  • Description: Write the value of the Term into stream provided by Stream.
  • The following properties should hold at call time:
    (basic_props:gnd/1)Stream is ground.
    (basic_props:term/1)Term is any term.

PREDICATE
Similarly to the previous predicate, this one serves currently as a wrap around the fast_read/2 predicate, and was implemented with the same purpose - to allow transparent switching to different stream reading systems.

Usage 1: read_pr(Stream,Term)

  • Description: Read stream represented by Stream looking for presence of pattern given by Term. If none found, the predicate does not block. Result found may be non-fully ground.
  • The following properties should hold at call time:
    (basic_props:gnd/1)Stream is ground.
    (basic_props:term/1)Term is any term.

Usage 2: read_pr(Stream,Term)

  • Description: Same as previous, with only modification - result found may be ground as well.
  • The following properties should hold at call time:
    (basic_props:gnd/1)Stream is ground.
    (basic_props:term/1)Term is any term.
  • The following properties should hold upon exit:
    (basic_props:gnd/1)Stream is ground.
    (basic_props:gnd/1)Term is ground.

Usage 3: read_pr(Stream,Term)

  • Description: Scan stream Stream for presence of concrete (exact) predicate given by value of Term. Term is fully bound.
  • The following properties should hold at call time:
    (basic_props:gnd/1)Stream is ground.
    (basic_props:gnd/1)Term is ground.
  • The following properties should hold upon exit:
    (basic_props:gnd/1)Stream is ground.
    (basic_props:gnd/1)Term is ground.