Simple types

The language allows values of the following simple types:

  • Numbers
  • Strings
  • Boolean
  • Nil
  • Other Types

Numbers

All numbers (even integers) are represented by IEEE 754 floating point values. Integers up to 2^54 have exact representations. Numeric values can be represented by:

  • Signed and unsigned decimal integers (examples: 10, -5)
  • Real numbers with decimal points (10.5, 3.14159)
  • Real numbers with exponents (1.0e+10)
  • Hexadecimals (0xffff0000)

Citrix ADC policy expressions have three numeric types:

  • 32-bit integers (num_at)
  • 64-bit integers (unsigned_long_at)
  • 64-bit floating point (double_at)

All of these are converted into the number type when passed into an extension function, and numbers are converted to the expected policy numeric type when returned.

Strings

Strings are byte sequences of any length. They correspond to the policy text_at type. Strings can contain null (0x00) bytes. Arbitrary binary data can be held in strings, including any character code representation (e.g. UTF-8 and full Unicode). However, string functions likestring.upper() assume 8-bit ASCII.

Strings are automatically allocated when used. There is no need (or even way) to explicitly allocate buffers for strings. Strings are also automatically deallocated by garbage collection when no longer in use. There is no need (or even way) to explicitly free strings. This automatic allocation and deallocation avoids some common problems in languages like C, such as memory leaks and dangling pointers.

String literals are character strings enclosed in double or single quotes. There is no difference between the two types of quotes: ”a string literal” is the same as ’a string literal’. The usual backslash escaping is available: \s (bell), \b (backspace), \f (form feed), \n (newline/line feed), \t (horizontal tab), \\ (backslash), \“(double quote), and \‘ (single quote). Decimal byte values can be entered by a backslash and one to three digits (\d, \dd, \ddd). Hexadecimal byte values can be entered by a backslash, an x, and two hex digits (\xhh)

A special syntax call the long bracket notation can be used for long, multi-line string literals. This notation encloses the string in double square brackets with zero or more equal signs between the brackets – the idea is to come up with a combination of brackets and equals that is not in the string. No escape sequences are honored in the string. Some examples:

[[This is a multi-line string using long bracket notation.]]

[=[This is a multi-line string using long notation with [[ and ]] and and an unescaped in it.]=]

Long bracket notation can be used to make a multi-line comment. Example:

–[[ This is a multi-line comment. –]]

Boolean

The usual true and false boolean values are provided. Note that boolean values are different than number values, in contrast to C where zero is assumed to be false and any non-zero value is true.

Nil

nil is a special value that means “no value”. It is its own type and is not equivalent to any other value, in contrast to C where NULL is defined to be zero.

Other types

There are two other types, userdata and threads. These are advanced topics and are not covered here.

Simple types