SWI-Prolog supports the data type string. Strings are a time and space efficient mechanism to handle text in Prolog. Atoms are under some circumstances not suitable because garbage collection on them is next to impossible (Although it is possible: BIM_prolog does it). Representing text as a list of ASCII values is, from the logical point of view, the cleanest solution. It however has two drawbacks: 1) they cannot be distinguished from a list of (small) integers; and 2) they consume (in SWI-Prolog) 12 bytes for each character stored.
Within strings each character only requires 1 byte storage. Strings live on the global stack and their storage is thus reclaimed on backtracking. Garbage collection can easily deal with strings.
The ISO standard proposes "..."
is transformed into a string
object by read/1 and derivates. This poses problems as in the old
convention "..."
is transformed into a list of ascii characters.
For this reason the style check option ` string' is available
(see style_check/2).
The set of predicates associated with strings is incomplete and tentative. Names and definitions might change in the future to confirm to the emerging standard.