Skip to main content
RequestScript is strictly typed. Every variable, parameter and resource function argument has a type, and values are checked against it.

Built-in types

Integers

int32 holds whole numbers from -2,147,483,648 to 2,147,483,647. int64 holds whole numbers from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Integers never wrap around. A result that doesn’t fit in its type is an overflow error:
See Operators for how integer arithmetic chooses its result type.

Decimals

decimal values are exact. They don’t suffer from the rounding errors of binary floating-point numbers:
To limit the size of a decimal, give it a precision with decimal(p, s), where p is the maximum number of digits before the decimal point and s is the maximum number after it:
The bounds are checked every time a value is stored in the variable or parameter, not just when it’s declared. A value that’s too large or too precise is an error. It is never rounded or truncated to fit.

Booleans

boolean has exactly two values, true and false. Conditions in if statements and the operands of !, && and || must be booleans. There is no “truthiness”: if (1) and if ("yes") are errors.

Strings

string holds text. String literals use double quotes and support escapes and interpolation.

Objects

An object maps property names to values. Objects are untyped: each property can hold a value of any type, including other objects and lists.

Lists

[]T is a list whose elements are of type T. List types nest, so [][]int32 is a list of lists of integers.
List indexes start at 0.

Null

null is a value of every type. You can assign it to any variable, pass it as any parameter or store it as any list element:

Numeric promotion

A numeric value is automatically promoted when a wider type is expected:
  • int32 is promoted to int64.
  • int32 and int64 are promoted to decimal.
  • An int64 value is accepted where int32 is expected only if it fits in the int32 range.
No other implicit conversions exist. In particular, a string is never converted to a number, and a number is never converted to a boolean:
The one place values are turned into strings is string concatenation and interpolation. See Operators.