In part one of the ISO standard for Prolog, ISO/IEC 13211-1:1995, the notion of "type" is used to refer to different things. This often leads to confusion. For example, a page called IsoErrata (archived version, source) states (note that this page is not related to ISO):
7.12.2 and 8.1.2.1
There is a confusion about what a "type" is. There seem to be 3 different groups:
- Those that are listed in 8.1.2.1 and also occur as ValidTypes in type_error terms in 7.12.2.b
- Those that are listed in 8.1.2.1 and occur as ValidDomain in domain_error terms in 7.12.2.c
- Those that are listed in 8.1.2.1 only
In addition, there are ValidDomains in 7.12.2.c that are not listed in 8.1.2.1, presumably by mistake (eg. io_mode).
8.14.3.3.f
The template requires the type
atom_or_atom_list
for the 3rd argument, but strangely the required error term here istype_error(list,Operator)
. This results in (see examples)
op(30,xfy,0) =====> error(type_error(list,0))
where
type_error(atom,0)
ortype_error(atom_or_atom_list,0)
would be more appropriate (but note thatatom_or_atom_list
is not among the ValidTypes listed in 7.12.2!). For ECLiPSe we have therefore opted fortype_error(list,Op)
only ifOp
is an improper list, andtype_error(atom,Op)
ifOp
is any other non-atom.
So in which meanings is "type" used, and what to do about above confusion?
There are essentially three different uses for "type" in ISO/IEC 13211-1:
Types as defined in 7.1 Types. These are: variable (7.1.1), integer (7.1.2), floating point (7.1.3), atom (7.1.4), compound term (7.1.5) and some types based on them. The next two uses will often refer to 7.1 or to terminology (3 Definitions) for its definition. What is important is that here, variables are included. This classification is motivated by Prolog's syntax:
Types as defined in 7.12.2 b. These are the types that are used in type errors which are of the form
type_error(ValidType, Culprit)
. Note that variables are now no longer included since these are either signaled as instantiation errors (7.12.2 a) or uninstantiation errors (7.12.2 k, Cor.2).Types as used in the Template and modes subclause:
Above quote mentioned only 7.12.2 and 8.1.2.1 and how they relate to each other. So this needs some more elaboration:
Types of 7.12.2 are reported with type errors. But types in 8.1.2.1 only serve in the Template and modes subclause of the definition of a built-in. They are not per se suited to be used for errors. In a concrete definition of a built-in predicate, there is a subclause x.y.z.2 Template and modes and x.y.z.3 Errors. Here are some examples of types of 8.1.2.1 (bold in the list above).
write_options_list
There is no direct one-to-one correspondence between
write_options_list
and the concrete types used in the errors. Instead, a typelist
and a domainwrite_option
is used. So the complex typewrite_option_list
is never signaled:atom_or_atom_list
This is even more complex. On the one hand an atom list is expected, but also an atom is fine. So we have
list
andatom
as relevant types:It is equally plausible to produce
atom
for error f. On the other hand, both errors are equally applicable, andlist
is definitely the best for malformed lists like[a|nonlist]
, whereasatom
is not necessarily better for111
which might be an OCR error of[l]
.callable_term
The corresponding type error contains
callable
. Like inin_character_code
There is neither a corresponding type in 7.12.2 b, nor a domain in 7.12.2 c. But in 7.12.2 f it is defined for representation errors:
io_mode
This is listed in 8.1.2.1, contrary to the quoted text. It also appears in 7.12.2 c and is used:
character_code_list
Similar to
write_options_list
. However, it is erroneously mentioned in 7.12.2 c. That's an error in the standard which has been removed in Cor.3:2017.