Type checking predicates. User extensible. New types can be defined by adding clauses for the
check/2 multifile predicates.
static, context_switching_calls, complements(restrict)
Logtalk specific types:
Prolog module related types (when the backend compiler supports modules):
Prolog base types:
Atom derived types:
Number derived types:
Float derived types:
Integer derived types:
List types (compound derived types):
Difference list types (compound derived types):
Other compound derived types:
predicate type notes: This type is used to check for an object public predicate specified as Object::Functor/Arity.
boolean type notes: The two value of this type are the atoms true and false.
Stream types notes: In the case of the
stream_or_alias(Property)types, Property must be a valid stream property.
order type notes: The three possible values of this type are the single character atoms
character_code type notes: This type takes into account Unicode support by the backend compiler. When Unicode is supported, it distinguishes between BMP and full support. When Unicode is not supported, it assumes a byte representation for characters.
between(Type, Lower, Upper) type notes: The type argument allows distinguishing between numbers and other types. It also allows choosing between mixed integer/float comparisons and strict float or integer comparisons. The term is type-checked before testing for interval membership.
property(Type, Lambda) type notes: Verifies that
Termsatisfies a property described using a lambda expression of the form
[Parameter]>>Goal. The lambda expression is applied in the context of
user. The term is type-checked before calling the goal.
one_of(Type, Set) type notes: For checking if a given term is an element of a set. The set is represented using a list. The term is type-checked before testing for set membership.
var_or(Type) notes: Allows checking if a term is either a variable or a valid value of the given type.
ground(Type) notes: Allows checking if a term is ground and a valid value of the given type.
types(Types) notes: Allows checking if a term is a valid value for one of the types in a list of types.
type notes: Allows checking if a term is a valid type.
qualified_callable notes: Allows checking if a term is a possibly module-qualified callable term. When the term is qualified, it also checks that the qualification modules are type correct. When the term is not qualified, its semantics are the same as the callable type.
Design choices: The main predicates are
check/3. These are defined using the predicate
check/2. Defining clauses for
valid/2gives the user full control of exception terms without requiring an additional predicate.
Error context: The built-in execution-context method
context/1can be used to provide the calling context for errors when using the predicate
Registering new types: New types can be registered by defining clauses for the
check/2multifile predicates. Clauses for both predicates must have a bound first argument to avoid introducing spurious choice-points when type-checking terms.
Meta-types: Meta-types are types that have one or more sub-types. E.g.
var_or(Type). The sub-types of a meta-type can be enumerated by defining a clause for the
Character sets: When testing character or character codes, or terms that contain them (e.g. atom), it is possible to choose a character set (
unicode_full) using the parameterizable types.
Caveats: The type argument (and any type parameterization) to the predicates is not type-checked (or checked for consistency) for performance reasons.
Table of defined types. A new type can be registered by defining a clause for this predicate and adding a clause for the
check/2 multifile predicate.
Table of defined meta-types. A registered type that is a meta-type can be described by defining a clause for this predicate to enumerate its sub-types and optional values in case of a single sub-type.
True if the given term is of the specified type. Fails otherwise.
True if the given term is of the specified type. Throws an error otherwise using the format
error(Error, Context). For the possible values of
Error see the
True if the given term is of the specified type. Throws an error otherwise. A new type can be added by defining a clause for this predicate and registering it by adding a clause for the
type/1 multifile predicate.
Termis not bound as required:
Termis bound but not of the specified type:
Termis the of the correct type but not in the specified domain:
Termis the of the correct type and domain but the resource it represents does not exist: