Repository navigation
block
pannous edited this page Oct 5, 2026
·
4 revisions
A block is unevaluated code meant to run later: an uncharged expression (vocabulary and timing: charged).
Blocks are written
- as an uncharged binding:
x : a+b - as statements in braces:
x = {print "hi"; 1+2} - with the prefix
codeorblock:xs = [code a+1, code a*2] - as the argument of a parameter declared
block:unless(c, body:block) := if !c: body!
A block runs with ! (once) or !! (fully, including nested blocks); names inside it resolve where ! is written.
Control flow takes blocks: if c {…}, while c {…}, for x in xs {…}, def f {…} run their block when they decide
to, see do.
A block used where a value is needed is a type error with the fix (x!, or x = … instead of x : …).
A block has no declared parameters; one that uses it is a one-parameter closure (map [1 2 3] {it*it}).
Unlike data, a block is meant to run.