======Type Checking====== Type-checking Operators allow a value's type to be checked. As well as [[PTPScript:Types|actual types]], there are also "pseudo-types" that can be checked for. ^ Symbol ^ [[PTPScript:Operators#Operator Types|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. ====Type descriptors==== There are two kinds of type descriptor - those that describe [[PTPScript:Types|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 [[PTPScript:Types:Array|Array]] | | ''boolean''~~~or~~~''bool'' | Comparison is **''true''** if the value is a [[PTPScript:Types:Boolean|Boolean]] | | ''float'' | Comparison is **''true''** if the value is a floating-point [[PTPScript:Types:Number|Number]] | | ''integer'' or ''int'' | Comparison is **''true''** if the value is an integer [[PTPScript:Types:Number|Number]] | | ''number'' | Comparison is **''true''** if the value is a [[PTPScript:Types:Number|Number]], whether integer or floating-point | | ''numeric'' | Comparison is **''true''** if the value is a [[PTPScript:Types:Number|Number]], or a [[PTPScript:Types:String|String]] containing a number | | ''string'' | Comparison is **''true''** if the value is a [[PTPScript:Types:String|String]] | ^ Pseudo-types ^^ | ''function'' | Comparison is **''true''** if the value is the name of a [[PTPScript:Functions|function]] that exists | | ''macro'' | Comparison is **''true''** if the value is the name of a [[PTPScript:Commands:Macro|macro]] that exists | | ''section'' | Comparison is **''true''** if the value is the name of a [[PTPScript:Commands:Section|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.