Passing Atoms

The foreign function interface allows Prolog atoms to be passed to functions either in a canonical form as unsigned integers, or as pointers to character strings.

For each Prolog atom there is a single canonical representation. Programs can rely on the property that identical atoms have identical canonical representations. Note, however, that the canonical form of an atom is not necessarily identical across different invocations of the program. This means that canonical atom representations should not be used in files or interprogram communication. For these purposes strings should be used. Foreign functions can store canonical atoms in data structures and pass them around and then back to Prolog, but they should not attempt any other operations on them.

Strings passed from Prolog to foreign functions should not be overwritten. Strings passed back from foreign functions to Prolog are automatically copied by Prolog if necessary. Thus the foreign program does not have to retain them and can reuse their storage space as desired.

There are three ways of passing atoms through the foreign interface:

  1. as canonical integers (to or from any language): see fli-p2f-atm-cat.
  2. as null-terminated strings (to or from C): see fli-p2f-atm-spc.
  3. as fixed-length, blank-padded strings (to or from FORTRAN or Pascal): see fli-p2f-atm-spc.