Data Types
iXML is a loosely typed language where the data type of a variable is often determined by the context in which it is used. However, the underlying runtime recognizes distinct intrinsic data types, and understanding them is essential for avoiding common bugs.
Type system overview
XML does not know intrinsic data types — in iXML, textual content is string by default unless converted by context or explicit cast. This is one of the most important facts for new iXML developers:
<set var="x">42</set> <!-- "42" is a string -->
<cast var="x" type="int" /> <!-- now 42 is an integer -->
The <set> command always produces a string. If your logic depends on numeric or boolean behavior, you must cast explicitly with cast or rely on automatic evaluation in contexts that expect a specific type (like int attributes).
Available types
iXML recognizes nine types, divided into primitive (assigned by value) and complex (assigned by reference):
| Type | Category | Neutral Literal | Description |
|---|---|---|---|
null | Primitive | NULL | Absence of a meaningful value |
bool | Primitive | FALSE | Truth value (TRUE or FALSE) |
int | Primitive | 0 | Whole number without fractional part |
float | Primitive | 0.0 | Number with fractional part |
string | Primitive | '' (empty) | Byte sequence or Unicode characters |
array | Complex | — | Ordered key-value collection |
function | Complex | — | Closed subroutine with local context |
macro | Complex | — | Open subroutine in caller's context |
class | Complex | — | Array prototype for OOP |
Use typeof to inspect a variable's type at runtime:
<set var="x">42</set>
<typeof var="x" var_result="t" />
<output>$t</output>
<!-- string -->
Detailed type guides
- Strings — the default type, string operations, and encoding
- Numbers — integers, floats, arithmetic context, and notation
- Booleans — truth values, truthiness rules, and comparison behavior
- Null and Undefined — the difference between null, undefined, and empty
- Arrays — ordered key-value collections, the primary complex type
- Type Conversion — casting rules, comparison behavior, and the conversion table