x-lang

← Index

x/core/syntax

Derived syntax forms: cond, case, when, unless, letrec.

These are operatives that extend the core syntax.

when

Evaluate body forms when test is true.

Parameters:

unless

Evaluate body forms when test is false.

Parameters:

letrec

Recursive let: all bindings are visible to each other, enabling mutual recursion.

Parameters:

let

Bind local variables and evaluate body.

Named let: (let name ((var init) …) body) creates a loop.

Parameters:

Examples:

(let ((x 1) (y 2)) (+ x y)) => 3
(let loop ((n 5) (acc 1)) (if (= n 0) acc (loop (- n 1) (* acc n)))) => 120

See also: letrec

cond

Multi-way conditional: evaluates clauses in order, returning the body of the first true test. Supports else and => syntax.

Parameters:

case

Dispatch on a value: evaluates key, then matches against datum lists in each clause.

Parameters: