Pyro

A scripting language for people who enjoy the simpler things in life.

Version 0.9.66

Checked Arithmetic


Pyro is implemented in C where signed integer overflow is undefined behaviour.

Overflow happens if the result of an integer operation is outside the range of the integer type — e.g. the addition operation i64_max + 1 will overflow because the sum of the two numbers is outside the range of the i64 type.

Pyro's arithmetic operators don't check for integer overflow. Instead, Pyro has a set of builtin functions for performing checked arithmetic.

$add(a: any, b: any) -> any

Checked addition. Returns a + b.

If a and b are both i64 values, this function will panic if the result of the operation would overflow.

$mul(a: any, b: any) -> any

Checked multiplication. Returns a * b.

If a and b are both i64 values, this function will panic if the result of the operation would overflow.

$sub(a: any, b: any) -> any

Checked subtraction. Returns a - b.

If a and b are both i64 values, this function will panic if the result of the operation would overflow.

Pyro doesn't have a dedicated function for checked division — the only case of integer division that can overflow is i64_min divided by -1.