Codes is the list consisting of the codes comprising the printed representation of Constant.
Initially, either Constant must be instantiated to a number or an atom, or Codes must be instantiated to a proper codes.
If Codes is instantiated to a proper codes that corresponds to the correct syntax of a number, Constant will be unified with that number.
Else if Codes is instantiated to a proper codes, Constant will be unified with the atom containing exactly those characters.
Else, Constant should be instantiated to a number or atom, and Codes will be unified with the codes that make up its printed representation.
There are atoms for which
true, but which will not be constructed if
name/2 is called
with Constant uninstantiated. One such atom is the atom
'1976'. It is recommended that new programs use
number_codes/2, as these predicates do
not have this ambiguity.
Constant is uninstantiated and Codes is not instantiated enough
If Constant is a compound term
An element of Codes is an invalid character code, or Codes is a list corresponding to a number or atom that can’t be represented
| ?- name(foo, L). L = [102,111,111]
| ?- name('Foo', L). L = [70,111,111]
| ?- name(431, L). L = [52,51,49]
| ?- name(X, [102,111,111]). X = foo
| ?- name(X, [52,51,49]). X = 431
| ?- name(X, "15.0e+12"). X = 1.5E+13