ISO/IEC 13211-1 中的“类型”基本上有三种不同的用途:
7.1 类型中定义的类型。它们是:变量 (7.1.1)、整数 (7.1.2)、浮点 (7.1.3)、原子 (7.1.4)、复合项 (7.1.5) 以及一些基于它们的类型。接下来的两个用法通常会参考 7.1 或术语(3 个定义)来进行定义。重要的是,这里包含了变量。这种分类是由 Prolog 的语法推动的:
7.1 类型
任何术语的类型由其抽象语法(6.1.2)决定。
7.12.2 b 中定义的类型。这些是在格式为 的类型错误中使用的类型type_error(ValidType, Culprit)
。请注意,变量现在不再包括在内,因为这些变量要么被表示为实例化错误(7.12.2 a)或非实例化错误(7.12.2 k,Cor.2)。
ValidType
∈ { }atom, atomic, byte, callable, character, compound, evaluable, float, in_byte, in_character, integer, list, number, pair, predicate_indicator
模板和模式子条款中使用的类型:
8.1.2.1 参数的类型
每个参数的类型由以下原子之一定义:
atom, atom_or_atom_list, atomic, byte, callable_term, character, character_code, character_code_list, character_list, clause, close_options_list, compound_term, evaluable, flag, head, in_byte, in_character, in_character_code, integer, io_mode, list, nonvar, number, operator_specifier, predicate_indicator, read_options_list, source_sink, stream, stream_options_list, stream_or_alias, stream_position, stream_property, term, write_options_list
上面的引用只提到了 7.12.2 和 8.1.2.1 以及它们之间的关系。所以这需要更多的阐述:
7.12.2 的类型报告有类型错误。但是 8.1.2.1 中的类型仅在内置的定义的模板和模式子条款中提供服务。它们本身不适合用于错误。在内置谓词的具体定义中,有一个子条款xyz2 模板和模式以及xyz3 错误。以下是 8.1.2.1 类型的一些示例(上面列表中的粗体)。
write_options_list
write_options_list
与错误中使用的具体类型之间没有直接的一一对应关系。相反,使用了类型list
和域write_option
。所以复杂类型write_options_list
永远不会发出信号:
8.14.2.2 模板和模式
write_term(@stream_or_alias, @term, @write_options_list)
8.14.2.3 错误
...
c)Options
既不是部分列表也不是列表
——type_error(list, Options).
...
e) 列表中的一个元素E
既不Options
是
变量也不是有效的写选项
——domain_error(write_option, E).
atom_or_atom_list
这更加复杂。一方面,原子列表是预期的,但原子也可以。所以我们有list
和atom
作为相关类型:
8.14.3.2 模板和模式
op(+integer, +operator_specifier, @atom_or_atom_list)
8.14.3.3 错误
...
f)Operator
既不是部分列表,也不是列表,也不是
原子
——type_error(list, Operator).
g) 列表中的元素E
既不Operator
是
变量也不是原子
——type_error(atom, E).
产生atom
误差 f 同样合理。另一方面,这两个错误同样适用,并且list
对于格式错误的列表(例如 )绝对是最好的[a|nonlist]
,而对于可能是 的 OCR 错误atom
不一定更好。111
[l]
callable_term
相应的类型错误包含callable
. 像
8.10.1.2 模板和模式
findall(?term, +callable_term, ?list)
8.10.1.3 错误
...
b) 目标既不是变量也不是可调用的术语
—— type_error(callable, Goal)
。
in_character_code
7.12.2 b 中既没有对应的类型,7.12.2 c 中也没有域。但在 7.12.2 f 中,它是为表示错误定义的:
8.12.1.2 模板和模式
...
get_code(?in_character_code)
get_code(@stream_or_alias, ?in_character_code)
8.12.1.3 错误
...
j)Code
是整数,但不是字符内代码
(7.1.2.2)
—representation_error(in_character_code).
io_mode
这在 8.1.2.1中列出,与引用的文本相反。它也出现在 7.12.2 c 中并用于:
8.11.5.3 错误
...
h)Mode
是原子但不是输入/输出模式
—
domain_error(io_mode, Mode).
character_code_list
类似于write_options_list
。但是,它在 7.12.2 c 中被错误地提及。这是Cor.3:2017中删除的标准中的错误。