- Called by open/3,4. The result argument must be unified with a stream.
- Called by access_file/2, exists_file/1
file) and exists_directory/1 (Mode is
directory). The result argument must be unified with a boolean.
- Called by time_file/2. The result must be unified with a time stamp.
- Called by size_file/2. The result must be unified with an integer representing the size in bytes.
- with_output_to(+Output, :Goal)
- Run Goal as once/1,
while characters written to the current output are sent to Output.
The predicate is SWI-Prolog-specific, inspired by various posts to the
mailinglist. It provides a flexible replacement for predicates such as
sformat/3 , swritef/3,
converting numbers to atoms, etc. The predicate format/3
accepts the same terms as output argument.
Applications should generally avoid creating atoms by breaking and concatenating other atoms, as the creation of large numbers of intermediate atoms generally leads to poor performance, even more so in multithreaded applications. This predicate supports creating difference lists from character data efficiently. The example below defines the DCG rule term//1 to insert a term in the output:
term(Term, In, Tail) :- with_output_to(codes(In, Tail), write(Term)). ?- phrase(term(hello), X). X = [104, 101, 108, 108, 111]
Output takes one of the shapes below. Except for the first, the system creates a temporary stream using the
wchar_tinternal encoding that points at a memory buffer. The encoding cannot be changed and an attempt to call