Declaring a variable

At first, there is no differentiation in types at all. Declaring any variable is done with the var keyword:

var count = 0;
var leading_zero = "0";

In the example above, both variables will have a number value of 0 and a string value of "0".

Atomic variables and collections

On another level, there is a differentiation between:

  1. ATOMIC (primitive)
  2. LIST (array)
  3. OBJECT (map)

These three are keywords in Xill, which can be compared (using the == operator) with the result of the System.typeOf function:  

if(System.typeOf(variable) == LIST) {
    variable = variable[0]; // if more than one result, just take the first
    // variable is now atomic

Different types of values for atomic variables

An atomic variable can hold a number, a string or a variety of other types of values, like even an Excel sheet or an iterable (see below). While programming and using proper naming, it should be intuitive what type of information is in the atomic variable you are working with, and therefore what you can do with them. What type of value every expression yields is predictable. For instance, the function Web.xPath(element,xpath,namespaces); can return null (which is an atomic), a string (atomic), a node (atomic) or a list.The used XPath determines whether the value will be a string or a node. If the XPath ends with '/text()', you will not be returned a node, but a string or a list of strings. Checking whether it is atomic or not is not necessary, because you can iterate through the (zero, one or many) results using the foreach loop.


Lists and objects are the two types of collections. An OBJECT has key-value pairs while a LIST only has numbered values. However: The true value of a Collection variable is not the object or list itself. It is a reference to the actual content, even though that is not visible in the code.

Read about the syntax of collections and/or follow the tutorial about collections.


A database query (like Document.find()), with possibly multiple results, returns an 'iterable' value. Iterables are held in ATOMIC variables, even though they can (and should) be looped over with a foreach loop. This is necessary for performance reasons, because a query result is potentially very large and therefore it is not desired (sometimes not possible) to load into memory. You could say that they are semantically a collection, but technically atomic.