O Language/API/Syntax: Difference between revisions
From OnixOS
Created page with "= Syntax = == Definitions and expressions == <pre> def answer = 6 * 7 def greeting = "Hello, " + "world!" output(answer) </pre> Statements may be separated with semicolons. Braces delimit blocks, hashes, and scopes. == Functions == <pre> def add = fn(left, right) { return left + right } output(add(2, 3)) </pre> Functions are first-class values and can be passed to <code>map</code>. == Conditions and iteration == Use <code>if</code> and <code>else</code> for br..." |
m Protected "O Language/API/Syntax" ([Edit=Allow only administrators] (indefinite) [Move=Allow only administrators] (indefinite)) |
(No difference)
| |
Latest revision as of 07:32, 25 August 2026
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.
