name(
?Constant,
?Chars)
If Constant is supplied, it should be an atom or
number.
Chars is unified with a list of character
codes representing the "name" of the constant. These are
precisely the characters that write/1
would write if
asked to write Constant.
If Constant is a variable, Chars should be
a proper list of character codes. If Chars looks like
the name of a number, Constant will be unified with
that number. The syntax for numbers that is accepted by name/2
is
exactly the one that read/1
accepts. If Chars does not
look like the name of a number, Constant will be
unified with an atom.
This attempt to guess what sort of constant you want means
that there are atoms that can be constructed by read/1
and by
atom_chars/2
, but not by name/2
.
name/2
is retained for backwards compatibility with
DEC-10 Prolog, C-Prolog, and earlier versions of Quintus
Prolog. New programs should use
atom_chars/2
or number_chars/2
, whichever is appropriate.
name/2
is a built-in predicate.
library(strings)
contains a predicate name1/2
, which is
identical to name/2
except that it reports errors in the same way as
other library predicates.