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.
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
string - strings variables hold a series of characters.
The value of a string variable may be
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
code - A function may have parameters that are of
function RunFunctionForAllPlayers takes code theFunction returns nothing
Would be called like this
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.
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.
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
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 nothingThe argument can be a
function DestroyUnit takes unit toDestroy returns nothingThe argument must be of type
A variable can be declared as an array of any basic type (i.e., non-array
type) except for
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,
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
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
... unit array myUnits unit array yourUnits ... set myUnits = yourUnits // illegal set myUnits = yourUnits // legal
|Copyright (c) 2003 Jeff Pang
Not affiliated or endorsed by Blizzard Entertainment