Fast reading and writing of terms
Author(s): Daniel Cabeza, Oscar Portela Arjona.
This library provides predicates to support reading / writing of terms on a format designed to be handled on read faster than standard representation.
Usage and interface
- Library usage:
:- use_module(library(fastrw)). - Exports:
- Predicates:
fast_read/1, fast_write/1, fast_read/2, fast_write/2, fast_write_to_string/3.
- Predicates:
- Imports:
- Packages:
prelude, nonpure, dcg, assertions, isomodes.
- Packages:
Documentation on exports
The next term is read from current standard input and is unified with Term. The syntax of the term must agree with fast_read / fast_write format. If the end of the input has been reached, Term is unified with the term 'end_of_file'. Further calls to fast_read/1 will then cause an error.
Output Term in a way that fast_read/1 and fast_read/2 will be able to read it back.
The next term is read from Stream and unified with Term. The syntax of the term must agree with fast_read / fast_write format. If the end of the input has been reached, Term is unified with the term 'end_of_file'. Further calls to fast_read/2 will then cause an error.
Usage:
- Call and exit should be compatible with:
(basic_props:term/1)Term is any term. - The following properties should hold at call time:
(streams_basic:stream/1)Stream is an open stream. - The following properties should hold upon exit:
(basic_props:term/1)Term is any term.
Output Term to Stream in a way that fast_read/1 and fast_read/2 will be able to read it back.
Usage:
- The following properties should hold at call time:
(streams_basic:stream/1)Stream is an open stream.
(basic_props:term/1)Term is any term. - The following properties should hold upon exit:
(basic_props:term/1)Term is any term. - The following properties should hold globally:
(basic_props:not_further_inst/2)Term is not further instantiated.
Known bugs and planned improvements
- Both fast_read/2 and fast_write/2 simply set the current output/input and call fast_read/1 and fast_write/1. Therefore, in the event an error hapens during its execution, the current input / output streams may be left pointing to the Stream