Standard Libraries

zb provides the following standard libraries from Lua:

Each of these libraries are available as globals and do not require importing. Unless otherwise noted, the behavior of every symbol in this section is as documented in the Lua 5.4 manual.

Basics (_G)

The following basic functions are available as globals:

The following variables are available as globals:

Intentionally absent are:

print is currently missing, but planned.

Mathematics

The following symbols are available in the math library:

Intentionally absent are:

String Manipulation

The following symbols are available in the string library:

Intentionally absent is:

string.unpack is currently missing but planned.

zb also sets a metatable for strings where the __index field points to the string table.

Patterns

Patterns behave a little differently in zb’s implementation in order to avoid pathological runtime performance and clean up some confusing behaviors. Patterns do not support backreferences (i.e. %0 - %9) or balances (i.e. %b). Attempting to use either of these pattern items will raise an error. In patterns, character sets with classes in ranges (e.g. [%a-z]) raise an error instead of silently exhibiting undefined behavior. However, ranges using escapes (e.g. [%]-`]) are well-defined in this implementation.

Table Manipulation

All of the symbols in the table library are available:

UTF-8

All of the symbols in the utf8 library are available:

Operating System

The only symbol available in the os library is os.getenv.

os.getenv(varname)

Returns the value of the process environment variable varname or fail if the variable is not defined or not in the allow-list of variables permitted by the user.

Parameters:
  • varname (string) – Environment variable name.

Return type:

string|nil