Type-checking Operators allow a value's type to be checked. As well as actual types, there are also "pseudo-types" that can be checked for.
Symbol | Type | Name | Description | Example |
---|---|---|---|---|
typeof | Prefix | TypeOf | Returns the actual type of the term's value | typeof a |
is | Infix | IsType | Checks if the value of the left term is of the actual type or pseudo-type specified by the type descriptor in the right term | a is int |
is not | Infix | IsNotType | Checks if the value of the left term is not of the actual type or pseudo-type specified by the type descriptor in the right term | a is not int |
is a | Infix | IsType | Optional form of is | a is a string |
is not a | Infix | IsNotType | Optional form of is not | a is not a string |
is an | Infix | IsType | Optional form of is | a is an integer |
is not an | Infix | IsNotType | Optional form of is not | a is not an integer |
is not
is a special form of is
that allows the inverse to be checked in a convenient manner without using parentheses.
For example:
{ a is not string } { !(a is string) }
Both expressions in the example above are equivalent.
Optionally, the words a
and an
can be used with is
and is not
, purely to make the expression more readable.
For example:
{ a is not string } { a is not a string }
Both expressions in the example above are equivalent.
There are two kinds of type descriptor - those that describe actual types, which are real data-types; and those that describe "pseudo-types", which are not data types at all, but additional types that are useful to use with the is
Operator.
Actual types | |
---|---|
array | Comparison is true if the value is an Array |
boolean or bool | Comparison is true if the value is a Boolean |
float | Comparison is true if the value is a floating-point Number |
integer or int | Comparison is true if the value is an integer Number |
number | Comparison is true if the value is a Number, whether integer or floating-point |
numeric | Comparison is true if the value is a Number, or a String containing a number |
string | Comparison is true if the value is a String |
Pseudo-types | |
function | Comparison is true if the value is the name of a function that exists |
macro | Comparison is true if the value is the name of a macro that exists |
section | Comparison is true if the value is the name of a section that exists |
validfile or validinclude or readablefile or readableinclude | Comparison is true if the value is the name of a file that is allowed to be included by the Include command, exists, and is readable |
existentfile or existentinclude | Comparison is true if the value is the name of a file that is allowed to be included by the Include command, and exists, without checking readability |
allowedfile or allowedinclude | Comparison is true if the value is the name of a file that is allowed to be included by the Include command, without checking existence or readability |
Type descriptors are case-insensitive.