Edva programs are composed from expressions: calls, choices, ranges, cycles, assignments, early returns, and blocks. For operator precedence and binding powers, see Operators, Sections & Underscore.
5.1 Calls and application
Form
Syntax
Associativity
Equivalent / Semantics
Direct call
f(a, b)
left (postfix, LBP 170)
Invokes f with positional arguments; no space before ( (E2032)
Chained call
f(a)(b)
left (postfix, LBP 170)
Calls the function value returned by f(a) with b
Nullary call
f!
left (postfix, LBP 170)
Invokes 0-argument function f (defined with !=>; f() is rejected with E2086)
Record copy-update
rec(k = v, ...)
left (postfix, LBP 170)
Copies nominal or anonymous record rec and overrides named fields k
Infix apply
f $ x / f(a) $ b
right (LBP 30, RBP 30)
Appends x / b as last argument: f(x) / f(a, b)
Block apply
f $ + indented block
right (LBP 30, RBP 30)
Passes indented k = v block as a single record argument
Feed
x $> f / x $> f(a) / x $> f(a, _) / x $> _(k = v)
left (LBP 40, RBP 50)
Prepends x as first argument (f(x) / f(x, a)); with a _ argument slot, fills that slot instead (s $> str::split(_, ",")\(\equiv\)str::split(s, ","), x $> Node(deps = d, ..._)); otherwise evaluates x once into _ when RHS has free _ or _(k = v)
Ram bind
ram $>> cont / ram $>> f(_, a)
left (LBP 40, RBP 50)
Threads positive payload of RamPN / RamPP into ram-returning cont, or into the _ argument slot of ram-returning f (opt $>> sub_opt(_, 3)) (E3091)
Ram positive map
ram $+> fn
left (LBP 40, RBP 50)
Maps fn: T => U over positive slot of < T | E > or < T | >, preserving negative slot (E3091)
Ram negative map
ram $-> fn
left (LBP 40, RBP 50)
Maps fn: E => F over negative slot of < T | E > or < | E >, preserving positive slot (E3091)
Composition
f .> g
left (LBP 40, RBP 50)
Left-to-right function composition ((f .> g)(x)\(\equiv\)g(f(x))), usable in pipelines or as a closure value
Coercion
Type(x) / x $> Type
—
Scalar width cast, nominal type construction, or empty container Type()
Both $ and the feed-tier operators ($>, $>>, $+>, $->, .>) sit below the choice tier (LBP 50), so an unparenthesized choice on their right-hand side is absorbed as the operand (f $ a [1] x | y\(\equiv\)f(a [1] x | y)). Pipeline operators ($>, $>>, $+>, $->, .>) can also begin an indented continuation line to form multiline pipelines.
5.2 Choice expressions
A choice expression evaluates a scrutinee against an ordered sequence of branches at the choice tier (LBP 50, RBP 60). The scrutinee is the entire preceding expression above LBP 50 (a + b [7] "x" | "y"\(\equiv\)(a + b) [7] "x" | "y").
5.2.1 Top-level choice forms
Form
Syntax
Result Type
Semantics
Guarded choice
s [g1] b1 [g2] b2 | fb
Unified body type
Evaluates first matching [g_i] branch body, or trailing | fb
Positional ram choice
r | pos_body | neg_body
Unified body type
First | matches positive slot; second | matches negative slot
Ram payload binding
r | x => b1 | err => b2
Unified body type
Binds slot payload to lambda parameter (or _ in implicit body)
Skip-first ram choice
r !| neg_body
Unified body type
Sugar for r | (void) | neg_body; skips unit positive slot (e.g. arr(i) = v !| _)
Bodyless guard
s [guard]
<> (Flag)
Evaluates to <+> on match, <-> otherwise
Negated guard
s ![guard]
<> (Flag)
Evaluates to <-> on match, <+> otherwise (! adjacent to [)
Scrutinee enum tag matches (comma OR-list supported for unit, bound, and deep subpatterns)
Juxtaposed identifier x binds payload; multi-pattern OR alternatives must bind the same variables (E2095). Explicit [Tag _] is forbidden (E2109; write [Tag])
Structural match across positional or named record fields (comma OR-list supported)
Subpatterns p_i may be literals, variable binders, _ wildcards, nested records, or enum variants; multi-pattern OR alternatives must bind the same variables (E2095)
Compile-time Type equality or structural shape match on T: Type
Prunes untaken branches before typecheck/codegen; binds inner Type parameters (P, N, E, K, V) in branch scope
5.2.2.1 Open, closed, and half-open interval guards
Range operators (.. and ... / ..=) always treat a present lower bound a as closed (inclusive), while the operator selects whether the upper bound b is open (.., exclusive) or closed (... / ..=, inclusive). For an open (exclusive) lower bound, use a chained-comparison predicate guard [(a < _ ...)]:
Range operators sit at LBP 70, RBP 80. Both ... and ..= denote inclusive upper bounds. Range endpoints must be adjacent to the operator with no whitespace (E2025). Ranges are not standalone first-class values (E3063); they are consumed by choice guards [...], cycles @, and collection/string slices x(...).
Cycles iterate at LBP 10, RBP 20 without keywords. @ and @@ are statement-valued cycles (()); @> and @@> are expression-valued cycles for map, filter-map, Builder accumulation, and seeded fold.
5.4.1 Iterable forms and loop binders
Iterable
Syntax
Explicit Binders
Implicit Block Binders (iterable @ + block)
Semantics
Count
n @ body
i => (0..n)
_ (Int), _i (Int)
Repeats n times (0 to n - 1)
Bounded range
a..b @ body a...b @ body
i => (Int)
_ (Int), _i (Int)
Iterates integer interval \([a, b)\) or \([a, b]\)
Condition (Flag<> / Ram)
(cond) @ body / cond @ body
—
—
Re-evaluates cond before each iteration; repeats while positive (<+> / <+ ... +>)
Iterates elements in index order 0..?xs (supports positional/named tuple or record destructuring)
Map K ^ V
m @ body
val => or val, key =>
_ (V value), _i (K key)
Iterates live map entries (value first, key second)
Record Type (#members)
#members T @ f => body
f => (field descriptor)
—
Compile-time unrolled over 0..#arity T (f.name, f.type, f.idx)
Enum Type (#members)
#members T @ v => body
v => (variant descriptor)
—
Compile-time unrolled over 0..#arity T (v.name, v.type, v.idx)
Element, index, and key binders shadow enclosing names for the cycle body and its >-- escape branch. The escape branch sees the values from the iteration that broke.
Evaluates body for each element (x =>, (a, b) =>, x, i =>, implicit _/_i, or point-free function/section/type/composition); returns Builder when U is Rune, or U{} otherwise
Filter-Map (RamPN/RamPP body)
items @> (x => cond | <+ u +>)
U{} (or Builder if U = Rune)
Unwraps and appends u on <+ u +>, skipping <--> / <- err ->
Direct freeze (+)
+(items @> body)
String
Builds into an implicit Builder when body returns any Builder-appendable chunk (Rune, String, Int byte, Builder, or tuple) and freezes directly to String
Seeded Builder
({}, items) @> body ({cap}, items) @> body
Builder
Initializes Builder seed and appends each iteration (x => chunk, point-free (.name), or b, x => b += ...)
Seeded Fold / Reduce
(seed, items) @> body
Acc
Initializes accumulator to seed: Acc and folds over items via acc, x =>, acc, (a, b) =>, acc, x, i =>, acc =>, or binary (Acc, E) => Acc ((+), (*), fn); returns seed on empty items
Conditional Fold
(seed, items) @> (acc, x => cond | <+ next +>)
Acc
Updates accumulator on <+ next +> and preserves current acc on <-->
A seeded fold binds its current accumulator to an immutable parameter for each iteration. The step’s result becomes the next accumulator. A Builder parameter can still append to its contents with +=.
Inside @>, --^ skips appending (map) or preserves the current acc (seeded fold), and --> stops early and returns the elements collected or acc accumulated so far.
#useionums =Int{}(1, 2, 3, 4)doubled = nums @> (_ *2)evens_sq = nums @> x => x %2==0|<+ x * x +>total = (0, nums) @> (+)io::out $ (doubled(0).expect("missing doubled"), ?evens_sq, evens_sq(1).expect("missing evens sq"), total)
Returns <+ esc_body +> if terminated by -->, or <--> on normal completion
#useiofound =1..10@ r =>1..10@ c => r * c ==42|-->2>--"hit 42"io::out $ found | _ |"none"
5.5 Assignments and mutations
Assignments sit at LBP 60, RBP 50 (right-associative) and always evaluate to ().
Target Form
Syntax
Semantics
Immutable binding
x = expr
Binds immutable local or module constant (E3033 on reassignment)
Rebindable binding
x' = expr
Declares or updates a primed mutable variable (x' or x = new_val)
Destructuring binding
(a, b) = pair (x, _, z) = triple (x = lx, y = ly) = pt
Positional or named tuple/record destructuring (supports _ wildcards, field = local renaming, and primed a' binders)
Marked global
::g = expr
Declares a module global mutable inside functions via g = expr or ::g = expr
Forward annotation
x: Type
Declares type without allocating storage (E3045 if read before write)
Append
b += expr / xs += elem
Appends in-place to Builderb or growable array xs (T{})
Builder length set
?b = n
Sets written byte length of Builderb to n
Field write
r.field = expr / r.0 = expr
Mutates record field in-place (tracks definite initialization, E3130)
Array / slice write
xs(i) = val
Writes slot i; returns < | Error > on T{} (xs(i) = val !| _ to panic on OOB)
Map insert / update
m ^ k = val
Inserts or overwrites key k with val in map m
Map key delete
m ^- k
Removes key k from map m; returns <> (<+> if removed, <-> if absent)
Volatile memory store
@[addr] = val
Stores val to raw memory address addr
5.6 Early return and branch return sugars
Form
Syntax
Desugaring
Enclosing Return Type
Value return
--| expr
—
Matches declared return type T
Void return
--|
—
() (void function)
Return negative flag
cond |->
cond | --| <->
<> (RamNN)
Return positive flag
cond |+>
cond | --| <+>
<> (RamNN)
Return option absence
cond |-->
cond | --| <-->
< T | > (RamPN)
Return fallible success
cond |++>
cond | --| <++>
< | E > (RamNP)
5.7 Type-directed unary and postfix forms
Form
Operand Type
Result Type
Semantics
!x
<> (Flag)
<>
Logical flag negation (E3008 on non-flag types)
+b
Builder
String
Freezes Builder into String in-place (\(O(1)\) buffer transfer)
?x
String, Builder, T{}, T[], (T * N), K ^ V, Type
Int
Byte, element, entry, field, or variant count
??s
String
Int
UTF-8 Unicode codepoint count
&x
String, Builder, composite, or call-arg scalar
Addr
Raw data pointer / buffer address (no space after &)
++x
String, Builder, record, T{}, T[]
Same as x
Deep arena copy
~~lvalue
Mutable variable, field, or collection slot
(get: () => T, set: T => ())
Two-way state binding lens record
x.expect("reason")
< A | B > or < A | >
A
Unwraps positive payload or aborts on negative slot (E3091 on <|B> / <>)
x--!
< A | E >, < A | >, < | E >, <>
A or ()
Unwraps positive slot or early-returns negative slot from enclosing function
expr {N}
Any expression, integer literal N
(T * N)
Repeats exprN times (splices flat inside tuple literals)
{} / {cap}
Optional Int capacity expression
Builder
Allocates Builder with default byte capacity (16) or explicit cap
@[addr T]
Addr, type T
T
Volatile typed memory load (or zero-copy record view)
#size T
Any type T
Int
Compile-time byte size of T
For preferred idioms across ambiguous-looking symbolic combinations, disambiguating {.dva .run} examples, and the 10-task symbolic comprehension baseline, see Operators, Sections & Underscore.