Skip to main content
This page covers the building blocks of RequestScript source text: how comments, whitespace, names and literal values are written.

Comments

A comment starts with // and runs to the end of the line. There are no block comments.

Whitespace and statements

Whitespace and line breaks don’t matter, and statements need no separator. Both of these scripts are valid:
return is the one exception. The value you return must start on the same line as the return keyword. If the value starts on the next line, the return is treated as a bare return and the script returns null.

Identifiers

Names of variables, object properties, parameters and resources are identifiers. An identifier starts with a letter or underscore, followed by any number of letters, digits or underscores. Identifiers are case-sensitive, so total and Total are different names.

Reserved keywords

These words can’t be used as identifiers: request contract var const return if else true false null Type names such as int32 and string are not reserved.

Number literals

Numbers are written as decimal digits, optionally with a fractional part:
  • Write negative numbers with the unary minus operator: -5.
  • A leading dot isn’t allowed: write 0.5, not .5.
  • There is no exponent notation (1e5), hexadecimal (0xFF) or digit separator (1_000).
Whole numbers that fit in 32 bits are int32, larger whole numbers are int64, and numbers with a fractional part are decimal. See Types.

String literals

Strings use double quotes and must fit on a single line.
These escape sequences are supported. Any other backslash sequence is an error. Strings can embed expressions with ${...}:

Other literals

  • Booleans: true and false.
  • Null: null.
  • Objects: { name: "Ada", age: 36 }.
  • Lists: [1, 2, 3].
Object and list literals are covered in Expressions.