O Language/API/Syntax

From OnixOS

Syntax

Definitions and expressions

def answer = 6 * 7
def greeting = "Hello, " + "world!"
output(answer)

Statements may be separated with semicolons. Braces delimit blocks, hashes, and scopes.

Functions

def add = fn(left, right) {
  return left + right
}

output(add(2, 3))

Functions are first-class values and can be passed to map.

Conditions and iteration

Use if and else for branches. Use while and loop for condition-based repetition. Use for with in to iterate arrays and hashes.

Scopes and modules

scope math {
  def double = fn(x) { return x * 2 }
}

output(math->double(4))
load "helpers.olm"

Other parser forms include proc, env, sock, route, signal, eval, async, wait, set, literal, and impl.