Skip to Content
Like this project? Star on Github! ⭐
LanguageExpressions

Expressions

Atoms

Null

null

Boolean

true
false

Number

All numbers in Rimu are “Big” Decimals , not floats or integers.

10
10.99

Octal integers use the 0o prefix and accept digits 07.

0o755

String

"hello world"

Escape quotes within strings to represent them literally.

"they said \"hello world\""

Function

(a, b) => a + b

Identifier

Identifiers must conform to regex: ^[a-zA-Z_][a-zA-Z0-9_]*$

hello

Collections

List

["hello", null, "world"]

Object

Unquoted keys must conform to Identifier regex: ^[a-zA-Z_][a-zA-Z0-9_]*$

Quoted keys can be any valid Unicode.

{ a: "apple", b: "bear" }
{ "a": "apple", "b": "bear" }

Operators

Unary

Operand must be a number.

- (negate)

-10

! (not)

Operand must be a boolean.

!is_done

Binary

+ (add)

Operands must be numbers, strings, lists, or paths.

10 + 2
"hello" + "world"
[1, 2] + [3, 4]

A path on the left and a string on the right extend the path. See host_path and target_path.

host_path("./dir") + "sub"
target_path("/etc") + "/hosts"

A string on the left and a path on the right concatenate as a plain string, dropping the path type — useful for embedding a path inside a non-path string (e.g. a podman volume entry).

"prefix:" + target_path("/etc")

- (subtract)

Operands must be numbers.

10 - 2

* (multiply)

Operands must be numbers.

10 * 2

/ (divide)

Operands must be numbers.

10 / 2

> (greater than)

Operands must be numbers.

10 > 2

>= (greater than or equal)

Operands must be numbers.

10 >= 2

< (less than)

Operands must be numbers.

10 < 2

<= (less than or equal)

Operands must be numbers.

10 <= 2

== (equal)

true == false

!= (not equal)

true != false

&& (and)

true && false

|| (or)

true || false

^ (xor)

Operands must be booleans.

true ^ false

% (remainder)

Operands must be numbers.

10 % 2

Call

Value being called must be a function.

add(1, 2)

Get Index

Container must be list or string or object.

list[2]
list[-2]
string[2]
object["a"]

Get Key

Container must be object

object.a

Get Slice

Container must be list or string.

list[2:5]
string[2:5]

Notes

Truthiness

Everything is truthy except false and null.

Orderedness

Only numbers are ordered.

No statements

Every expression is evaluated to a value.

No type coercion

No implicit type coercions.

For example, the following is an error:

2 + "pies"
Last updated on