Functions
Function literals, calls, closures, and current constraints.
Functions are first-class values in Jot.
Defining a function
let add = fn(a, b) a + b
print(add(1, 2))Syntax:
fn(param1, param2, ...) expression- Parameters are identifiers.
- Parameter names must be unique.
- Function body is a single expression.
Calling functions
let inc = fn(x) x + 1
print(inc(41))Arity is checked at runtime.
Closures
Functions capture outer values when created.
let x = 10
let f = fn() x
x = 20
print(f())Current behavior prints 10.
Current constraints
- No named function declaration syntax yet (
fn name(...) ...is not in grammar). - No direct recursion syntax at this stage.