JASS Tools
JASS Manual


JASS has a type system that helps to ensure correctness of assignments and expressions (i.e., that you don't assign strings to integer variables or try to add two units together). There are several native types which are predefined, but users can also declare subtypes of the basic native types. An array of any type can also be declared.

Native Types

integer - integer variables can hold the range of integral numbers ranging from -2147483647 to 2147483647.

real - real variables can hold rational numbers (i.e., floating-point or fractional numbers). One assumes the values are 32-bit and conform to the IEEE Standard 754 Floating-Point standard (someone want to verify this?).

boolean - boolean variables can take on the values true or false. Boolean values are returned by boolean operations and predicates to "if" statements must be boolean types.

string - strings variables hold a series of characters. The value of a string variable may be null in which case the variable refers to nothing and it is illegal to use it (except to assign a value to it).

handle - a handle variable is basically a "pointer". It refers to some data structure that is internal to Warcraft III which you can not manipulate directly. All user-defined types inherit from handle. For example, a unit is a subtype of handle that points to some unit data-structure in the game. Any handle variable can be assigned the value null, which means it refers to nothing.

code - A function may have parameters that are of type code. This means it must take a function reference as an argument. This is similar to a function pointer in C or C++. A function is referenced with the expression function func_name. For example, a function with the prototype:

function RunFunctionForAllPlayers takes code theFunction returns nothing

Would be called like this RunFunctionForAllPlayers(function someFunction).

A code value can also be null, which means it refers to no function (and should not be used in any native function).

User-Defined Types

The handle type can be subtyped, meaning users can define more specific classes of handles. See Global Declarations for more information. All types used in native functions are declared in common.j.

A type new_type which extends another type parent_type is said to be a child of parent_type. For example, widget is a child of handle and unit is a child of widget. The arrangement of children forms a type-tree which is rooted at the base-type, handle.

We define any type to be an ancestor of itself. In addition, a type a is an ancestor of type b if b is the child of some type c, which a is also the ancestor of (i.e., ancestry is transitive). In other words, a is an ancestor of b if there is a path going down from a to b in the type-tree. For example, if c extends a, d extends c, and b extends d, then a is an ancestor of b, and so are c and d. See Figure 1.

type tree example
Figure 1. A type tree. Example: handle is an ancestor of player and unit.

We say type b conforms to type a if a is an ancestor of b. If a variable is of type b and b conforms to a, then the variable is a a as well as a b. For example, a unit variable is a widget as well as a handle, since unit conforms to both.

The bottom-line is that a function that has a parameter of type a can take any argument that is a value of type a. For example, given the following function declaration:

function DestroyWidget takes widget toDestroy returns nothing
The argument can be a unit, destructable, item, or widget, since all those types conform to the type widget. Note however that the converse is not true. If the function was declared as:
function DestroyUnit takes unit toDestroy returns nothing
The argument must be of type unit and not widget because a widget is not necessarily a unit.


A variable can be declared as an array of any basic type (i.e., non-array type) except for code (code array is not legal). See Global Declarations for more information.

Array variables are initialized to "empty" values (e.g., 0 for integer arrays, and null for handle arrays) and have a fixed size. Each index in an array holds a value of its declared type and is referenced with the standard bracket notation. For example, my_array[10] refers to the 11th element of my_array.

Although you can store an element in any index of an array (from 0 to the maximum positive integer value), you can only store up to JASS_MAX_ARRAY_SIZE = 8192 elements total in a given array (defined in common.j). In other words, an array is more like a sparse hashtable with a fixed size of 8192. (Note: I have not verified this)

Functions may not take arrays as arguments, nor may arrays be returned from functions. Array variables can not be reassigned (i.e., it is illegal to call set on an array variable). This means the following is illegal:

     unit array myUnits
     unit array yourUnits
     set myUnits = yourUnits         // illegal
     set myUnits[0] = yourUnits[10]  // legal

Copyright (c) 2003 Jeff Pang
Not affiliated or endorsed by Blizzard Entertainment
SourceForge.net Logo