Formatted Output

This file includes the definition of the formatted output predicates.

Define:

1. TMP_STRING_SIZE:

1. TOO_FEW_ARGUMENTS:

Functions:

1. static void format_clean_up(int sno, int sno0, format_info *finfo):

1. static int format_print_str(int sno, Int size, bool has_size, Term args, int(f_putc)(int, wchar_t), format_info finfo):

1. static Int format_copy_args(Term args, Term targs, Int tsz, int sno, format_info finfo):

1. static Int fetch_index_from_args(Term t):

1. static wchar_t base_dig(Int dig, Int ch):

1. static Int doformat(volatile Term otail, volatile Term oargs, int l, int sno0 USES_REGS):

1. static Int with_output_to(USES_REGS1): : "with_output_to(+ Ouput,: Goal" )

@class with_output_to_2

Run Goal as once_49 "once/1", while characters written to the current output are sent to Output. The predicate was introduced by SWI-Prolog.

The example below defines the DCG rule \@ref term_51 \@"term/3" to insert a term in the output:

@icode term(Term, In, Tail) :- with_output_to(codes(In, Tail), write(Term)).

?- phrase(term(hello), X).

X = [104, 101, 108, 108, 111] @endicode

  • A Stream handle or alias Temporary switch current output to the given stream. Redirection using @ref with_output_to_50 @"with_output_to/2" guarantees the original output is restored, also if Goal fails or raises an exception. See also @ref call_cleanup_50 @"call_cleanup/2".
  • atom(- Atom) Create an atom from the emitted characters. Applications should generally avoid creating atoms by breaking and concatenating other atoms as the creation of large numbers of intermediate atoms puts pressure on the atom table and the data-base. This may lead to collisions in the hash tables used to implement atoms, and may result in frequent calls to the garbage collector. In multi-threaded applications, access to the atom table is controlled by locks. This predicate supports creating the therms by expanding difference-list.

  • string(- String) Create a string-object, notice that strings are atomic objects.

  • codes(- Codes) Create a list of character codes from the emitted characters, similar to @ref atom_codes_50 @"atom_codes/2".
  • codes(- Codes, - Tail) Create a list of character codes as a difference-list.
  • chars(- Chars) Create a list of one-character-atoms codes from the emitted characters, similar to @ref atom_chars_50 @"atom_chars/2".

  • chars(- Chars, - Tail) Create a list of one-character-atoms as a difference-list.

1. static Int format(Term tf, Term tas, Term tout USES_REGS):

1. static Int forma/2(USES_REGS1):

1. static Int forma/3(USES_REGS1):

1. void Yap_InitFormat(void):