syntax_error
exception is raised if CharList is instantiated to a ground,
proper list but does not represent a valid Prolog number.Following the ISO standard, the Prolog syntax for number allows for leading white space (including newlines) and does not allow for trailing white space.120ISO also allows for Prolog comments in leading white space. We--and most other implementations--believe this is incorrect. We also believe it would have been better not to allow for white space, or to allow for both leading and trailing white space.
Beyond ASCII, decimal digits in the input may come from any Unicode
decimal digit block (general category Nd); see
section 2.15.1.9. All
digits in a single number must come from the same block --- for
an integer, for the numerator and denominator of a rational, and for the
mantissa and exponent of a floating-point number. The optional sign (, +),
the rational separator (-r or ),
the floating-point decimal point (/) and the
floating-point exponent letter (.e,
E) are always ASCII; their non-ASCII look-alikes raise
syntax_error.
Prolog syntax-based conversion can also be achieved using format/3 and read_from_chars/2.