Operators
Overview
| Category | Operators |
|---|---|
| Pipe | -> |
| Capture | => |
| Arithmetic | +, -, *, /, % |
| Comparison | ==, !=, <, >, <=, >= |
| Comparison Methods | .eq, .ne, .lt, .gt, .le, .ge |
| Logical | ! (unary), &&, ` |
| Chain | chain($fn), chain([...]) |
| Ordered | ordered[k: v] (named ordered container) |
| Extraction | destruct<...> (destructure), slice<...> (slice) |
| Convert | -> type (type conversion) |
| Type | :type (assert), :?type (check) |
| Member | .field, [index] |
| Hierarchical Dispatch | [path] -> target |
| Default | ?? value |
| Existence | .?field, .?field&type |
| Status probe | .! (bool: is the value invalid), .!field (sidecar field: code, message, provider, trace, or a raw key) |
Pipe Operator ->
v -> target evaluates the target with the value v, by the kind of the target.
"hello" -> .upper # "HELLO"
42 -> ($ + 8) # 50
[1, 2, 3] -> seq({ $ * 2 }) # list[2, 4, 6]| Target | What -> does | Example |
|---|---|---|
type T | converts; see Conversion Operator | "5" -> number |
| list, dict, tuple, ordered, map | selects | 0 -> list["a", "b"] |
| code block | runs once with $ bound | 3 -> { $ + 1 } |
| string | is built with $ bound | 5 -> "x{$}" |
function $f | calls it with the value as its one argument | 5 -> $double |
method .m | calls the method on the value | "hi" -> .upper |
call f(args) or $h(args) | prepends the value unless a top-level $ places it; see Pipe Binding Rule | list[1, 2, 3] -> take(2) |
( expr ) | evaluates with $ bound | 5 -> ($ * $ + $) |
variable $x | does what its value calls for; halts RILL-R002 otherwise | 1 -> $t |
:T, :?T | asserts or checks, never converts | 5 -> :number |
| number, bool, or atom literal | is not a target; halts RILL-P001 | 5 -> 3 |
fn(x) { $x * 2 } => $double
tuple["x", "y"] => $t
tuple["5" -> number, 0 -> list["a", "b"], 3 -> { $ + 1 }, 5 -> "x{$}", "hi" -> .upper, 5 -> $double, list[1, 2, 3] -> take(2), 5 -> ($ * 2), 1 -> $t]
# Result: tuple[5, "a", 4, "x5", "HI", 10, list[1, 2], 10, "y"]A :T target asserts and never converts, so a string does not become a number:
# Error: #TYPE_MISMATCH
"5" -> :number5 -> :number
# Result: 5A code block target that never reads $ is rejected where written:
# Error: RILL-P031
3 -> { 5 }A zero-parameter function takes no piped value:
# Error: RILL-R045
fn() { 7 } => $z
3 -> $zA block written inside a collection is held, and selecting its entry runs it:
0 -> list[{ 5 }]
# Result: 5dict[a: { 5 }] => $d
$d.a
# Result: 5A bare block captured with => runs where it is written, so the variable holds its result:
{ 5 } => $x
$x
# Result: 5A Target Uses the Piped Value
A block or string target must read $. A leading method such as .upper or pass counts as a read. A list or dict literal target must not read $ at its top level. Wrap the literal in a block to use the value twice. A $ inside a nested held block is fine. A call with no arguments does not count.
3 -> { list[$, $] }
# Result: list[3, 3]# Error: RILL-P030
3 -> list[$, $]# Error: RILL-P031
5 -> "x"# Error: RILL-P001
5 -> 3# Error: RILL-R002
3 => $n -> $nPiping into a zero-parameter function halts RILL-R045, because the piped value is an excess argument.
fn() { "constant" } => $zero
# Error: RILL-R045
42 -> $zeroMethod Syntax
Method calls are sugar for pipes:
"hello".upper # equivalent: "hello" -> .upper
"hello".contains("ell") # equivalent: "hello" -> .contains("ell")Implicit $
Bare .method() implies $ as receiver:
"hello" -> {
.upper -> log # $."upper" -> log
.len # $.len
}Pipe Binding Rule
When -> targets a callable, the runtime decides how to bind the piped value to arguments. Two rules apply, checked in order:
Rule 1 — Explicit $ (manual placement). The runtime scans the immediate argument list for $. If at least one top-level $ is found, every occurrence resolves to the piped value. No auto-prepend occurs.
Rule 2 — Auto-prepend. If no top-level $ is found in the argument list, the piped value is prepended as the first argument automatically.
Zero-parameter callables. Auto-prepend into a zero-parameter callable halts RILL-R045; see A Target Uses the Piped Value.
Argument blocks stop the scan. The scanner walks the immediate argument list but stops at block boundaries ({). References to $ inside an argument block are not counted: a block that is a whole argument converts to a function typed by the unnamed parameters its body reads, and the callee binds $ per call. Only top-level $ in the argument list triggers explicit placement. See Functions and Code Blocks for argument blocks and Collections for the exact arity each operator requires.
Sub-expressions are scanned. The scanner descends into sub-expressions outside blocks. fn(g($)) contains a top-level $ inside g(...), so explicit placement is used.
Worked Examples
| Call form | $ in top-level args? | Effective call | Notes |
|---|---|---|---|
$val -> fn | n/a (no args) | fn($val) | Auto-prepend |
$val -> fn() | n/a (empty args) | fn($val) | Auto-prepend |
$val -> fn (fn takes 0 params) | n/a | fn($val) | Halts RILL-R045: excess argument |
$val -> fn(1, 2) | no | fn($val, 1, 2) | Auto-prepend |
$val -> fn($) | yes | fn($val) | Explicit: single $ |
$val -> fn(1, $, 0) | yes | fn(1, $val, 0) | Explicit: middle position |
$val -> fn(1, $, $) | yes | fn(1, $val, $val) | Explicit: both resolve to piped value |
$val -> fn(g($)) | yes (inside sub-expr) | fn(g($val)) | Sub-expr $ counts as top-level |
$list -> filter({ $.active }) | no (block boundary stops scan) | filter($list, { $.active }) | Block $ is bound per element |
$matrix -> seq({ $ -> seq({ $ * 2 }) }) | no (outer block stops scan) | seq($matrix, { $ -> seq({ $ * 2 }) }) | Nested blocks; outer and inner $ both bound per call |
Auto-prepend — no args
When a callable is called with no arguments, the piped value is prepended automatically.
fn(x) { $x * 2 } => $double
5 -> $double
# Result: 10Auto-prepend — existing args
When a function is called with existing args and no top-level $, the piped value is prepended as the first argument. The existing args shift right. This applies to built-in, host, and script functions in pipe-target position.
[1, 2, 3] -> fold(0, { $@ + $ })
# fold([1, 2, 3], 0, { $@ + $ }) — list auto-prepended
# Result: 6fn(a, b) { $a - $b } => $sub
10 -> $sub(3)
# Result: 7Explicit placement with $
fn(a, b, c) { "{$a},{$b},{$c}" } => $fmt
10 -> $fmt(1, $, 0)
# Result: "1,10,0"Duplicate $ — both resolve to piped value
fn(a, b, c) { "{$a},{$b},{$c}" } => $fmt
10 -> $fmt(1, $, $)
# Result: "1,10,10"Sub-expression $ counts as top-level
fn(x) { $x * 2 } => $double
fn(n) { $n + 1 } => $inc
5 -> $double($inc($))
# Result: 12The $ inside $inc($) is a top-level $ in the argument list of $double, so explicit placement is used. The piped value 5 goes to $inc, producing 6, which becomes the single argument to $double.
Block $ is bound per call — not counted by the scanner
[[active: true, name: "a"], [active: false, name: "b"], [active: true, name: "c"]] -> filter({ $.active })
# Result: list[dict[active: true, name: "a"], dict[active: true, name: "c"]]The $ inside { $.active } is inside a block boundary. The scanner stops there and finds no top-level $. Auto-prepend activates: the list is prepended as the first argument to filter, and the block is passed as the second argument as a function. Inside the block, $ is bound to each element during iteration.
Nested blocks — each $ is bound per call
[[1, 2, 3], [4, 5, 6]] -> seq({ $ -> seq({ $ * 2 }) })
# Result: list[list[2, 4, 6], list[8, 10, 12]]Both the outer { $ -> ... } and the inner { $ * 2 } bind $ per call. Neither counts toward the pipe-site scan for the top-level seq call. Auto-prepend places the list as the first argument.
Capture Operator =>
Captures a value into a variable:
"hello" => $greeting # store in $greeting
42 => $count # store in $countv => $x binds v and passes v on unchanged. A capture evaluates nothing: it never converts, calls, or selects. => $x:T asserts, as -> :T does. A block before => runs by its own rule, so { 5 } => $x binds 5. Store a function with fn { 5 } => $x. See Code Blocks.
guard { "5" => $x:number } => $r
$r.!code == #TYPE_MISMATCH
# Result: trueCapture and Continue
=> captures AND continues the chain:
"hello" => $a -> .upper => $b -> .len
# $a is "hello", $b is "HELLO", result is 5See Variables for detailed scoping rules.
Arithmetic Operators
| Operator | Description |
|---|---|
+ | Addition |
- | Subtraction |
* | Multiplication |
/ | Division |
% | Modulo (remainder) |
5 + 3 # 8
10 - 4 # 6
3 * 4 # 12
15 / 3 # 5
17 % 5 # 2Precedence
Standard mathematical precedence (high to low):
- Unary:
-,! - Multiplicative:
*,/,% - Additive:
+,-
2 + 3 * 4 # 14 (multiplication first)
(2 + 3) * 4 # 20 (parentheses override)
-5 + 3 # -2Type Constraint
All operands must be numbers. No implicit conversion:
5 + 3 # OK: 8"5" + 1 # ERROR: Arithmetic requires number, got stringError Handling
10 / 0 # ERROR: Division by zero
10 % 0 # ERROR: Modulo by zeroComparison Operators
| Operator | Description |
|---|---|
== | Equal |
!= | Not equal |
< | Less than |
> | Greater than |
<= | Less or equal |
>= | Greater or equal |
5 == 5 # true
5 != 3 # true
3 < 5 # true
5 > 3 # true
5 <= 5 # true
5 >= 3 # trueValue Comparison
All comparisons are by value, not reference:
[1, 2, 3] == list[1, 2, 3] # true
[a: 1] == dict[a: 1] # true
"hello" == "hello" # true== and != halt with #TYPE_MISMATCH when the operand types cannot overlap, including a value outside a declared closed set of literals or atoms (see Literal Members). Values of overlapping types that differ in kind compare unequal. An element read from an undeclared list carries its own type, so list[1, "a"] -> filter({ $ == "a" }) halts on 1. Declare the list as list(union(number, string)) to compare across its types. An empty list overlaps a list of numbers, so the comparison runs:
list[] == list[1]
# Result: false# Error: #TYPE_MISMATCH
1 == "1"Comparison Methods
Methods provide readable alternatives in conditionals:
| Method | Equivalent |
|---|---|
.eq(val) | == val |
.ne(val) | != val |
.lt(val) | < val |
.gt(val) | > val |
.le(val) | <= val |
.ge(val) | >= val |
"A" => $v
$v -> .eq("A") ? "match" ! "no" # "match"
5 -> .gt(3) ? "big" ! "small" # "big"
10 -> .le(10) ? "ok" ! "over" # "ok"Logical Operators
| Operator | Description |
|---|---|
&& | Logical AND (short-circuit) |
|| | Logical OR (short-circuit) |
! | Logical NOT |
(true && false) # false
(true || false) # true
!true # false
!false # trueShort-Circuit Evaluation
(false && undefined_var) # false (right side not evaluated)
(true || undefined_var) # true (right side not evaluated)With Comparisons
(1 < 2 && 3 > 2) # true
(5 > 10 || 3 < 5) # trueGrouping Required
Compound expressions require grouping in simple-body contexts:
true -> ($ && true) ? "both" ! "not both" # "both"Negation in Pipes
In pipe targets, !expr binds tightly and returns a boolean:
"hello" -> !.empty # true (not empty)
"" -> !.empty # false (is empty)This works naturally with conditionals and captures:
"hello" -> !.empty ? "has content" ! "empty" # "has content"
"hello" -> !.empty => $not_empty # $not_empty = trueNo grouping needed; !.empty is parsed as a unit before ? or =>.
Chain and Ordered
chain() Built-in
chain pipes a value through a sequence of functions. Each function receives the result of the previous one.
Chain a list of functions:
fn(x) { $x + 1 } => $inc
fn(x) { $x * 2 } => $double
fn(x) { $x + 10 } => $add10
# Chain: (5 + 1) = 6, (6 * 2) = 12, (12 + 10) = 22
5 -> chain([$inc, $double, $add10]) # 22Chain a single function:
fn(x) { $x * 2 } => $dbl
5 -> chain($dbl) # 10ordered[...] Literal
ordered[...] produces a named, ordered container. It preserves insertion order and carries named keys. Use it to pass named arguments to functions:
fn(a, b, c) { "{$a}-{$b}-{$c}" } => $fmt
dict[c: 3, a: 1, b: 2] -> $fmt(...) # "1-2-3" (names matched, key order irrelevant)ordered values convert to plain objects via toNative(). The native field holds { key: value, ... }. Functions, iterators, vectors, and type values produce native: null.
See Types for full type documentation.
Extraction Operators
Destructure destruct<>
Extract elements from lists, tuples, or dicts (keyed patterns also accept ordered) into variables. Other sources halt with RILL-R002. Returns the original value unchanged.
List destructuring (pattern count must match element count):
[1, 2, 3] -> destruct<$a, $b, $c>
# $a = 1, $b = 2, $c = 3With dict destructuring:
[code: 0, msg: "ok"] -> destruct<code: $code, msg: $msg>
# $code = 0, $msg = "ok"Skip elements with _:
[1, 2, 3, 4] -> destruct<$first, _, _, $last>
# $first = 1, $last = 4Dict destructuring (explicit key mapping):
[name: "test", count: 42] -> destruct<name: $n, count: $c>
# $n = "test", $c = 42Nested destructuring:
[list[1, 2], list[3, 4]] -> destruct<destruct<$a, $b>, destruct<$c, $d>>
# $a = 1, $b = 2, $c = 3, $d = 4Errors:
[1, 2] -> destruct<$a, $b, $c> # Error: pattern has 3 elements, list has 2
[name: "x"] -> destruct<name: $n, age: $a> # Error: key 'age' not found
[1, 2] -> destruct<$a, k: $b> # Error: RILL-P026, positional and keyed elements mixedType-Annotated Destructure
Capture variables in destruct<> accept type annotations using :type syntax. The runtime validates the extracted element against the declared type before assignment.
Parameterized type on a destructure capture:
[["a", "b"]] -> destruct<$a:list(string)>
$a[0]
# Result: "a"Dict structural type on a destructure capture:
[[name: "alice"]] -> destruct<$a:dict(name: string)>
$a.name
# Result: "alice"Union type on a destructure capture:
["hello"] -> destruct<$a:union(string, number)>
$a
# Result: "hello"Type mismatch error:
# Error: Type mismatch: cannot assign list(number) to $a:list(string)
[[1, 2]] -> destruct<$a:list(string)>Slice slice<>
Extract a portion using Python-style start:stop:step. Works on lists, tuples, and strings; other sources halt with RILL-R002.
Basic slicing:
[0, 1, 2, 3, 4] -> slice<0:3> # list[0, 1, 2]
[0, 1, 2, 3, 4] -> slice<1:4> # list[1, 2, 3]Omitted bounds:
[0, 1, 2, 3, 4] -> slice<:3> # list[0, 1, 2] (first 3)
[0, 1, 2, 3, 4] -> slice<2:> # list[2, 3, 4] (from index 2)Negative indices:
[0, 1, 2, 3, 4] -> slice<-2:> # list[3, 4] (last 2)
[0, 1, 2, 3, 4] -> slice<:-1> # list[0, 1, 2, 3] (all but last)Step:
[0, 1, 2, 3, 4] -> slice<::2> # list[0, 2, 4] (every 2nd)
[0, 1, 2, 3, 4] -> slice<::-1> # list[4, 3, 2, 1, 0] (reversed)String slicing:
"hello" -> slice<1:4> # "ell"
"hello" -> slice<::-1> # "olleh"Edge cases:
[1, 2, 3] -> slice<0:100> # list[1, 2, 3] (clamped)
[1, 2, 3] -> slice<2:1> # [] (empty when start >= stop)A step of 0 halts with #INVALID_INPUT, which guard catches.
guard { list[1, 2, 3] -> slice<::0> } => $r
$r.!code -> string
# Result: "INVALID_INPUT"Member Access Operators
Field Access .field
Access dict fields:
[name: "alice", age: 30] => $person
$person.name # "alice"
$person.age # 30See Types for dict .keys and .entries documentation.
Index Access [n]
Access list elements (0-based, negative from end):
["a", "b", "c"] => $letters
$letters[0] # "a"
$letters[-1] # "c"
$letters[1] # "b"The index must be an integer. An out-of-range index halts with RILL-R009 and a non-integer index halts with #INVALID_INPUT; both are catchable, and .at(n) ?? default supplies a default.
["a", "b", "c"] => $letters
$letters -> .at(5) ?? "none"
# Result: "none"Variable Key .$key
Use a variable as key:
"name" => $key
[name: "alice"] => $data
$data.$key # "alice"Computed Key [expr]
Use an expression as key. A numeric key indexes a list under the same rules as [n]. A dict key must be a string; see Types for the rule.
["a", "b", "c"] => $letters
$letters[0 + 1]
# Result: "b"Computed Existence .?[expr]
dict[name: "Al"] => $user
$user.?["name"]&string
# Result: true.?[expr] validates its selector as the bracket read [expr] does. Only a genuine miss, an absent key or an out-of-range index, yields false.
A selector of the wrong type halts with the error the read raises, and ?? does not recover it. A non-string selector on a dict halts #TYPE_MISMATCH, and list[1, 2].?["a"], tuple[1].?[true], ordered[a: 1].?[list[1]], and "s".?["len"] halt with the error the bracket read raises. See Types for the key rule.
list["a", "b"] => $letters
$letters.?[5]
# Result: falseFallback Across Fields
# ?? chains try fields left-to-right
dict[age: 30] => $u
$u.name ?? $u.nickname ?? "unknown"
# Result: "unknown"Hierarchical Dispatch
Navigate nested data structures using a list of keys/indexes as a path:
["name", "given"] -> [name: dict[given: "Alice", last: "Smith"]]
# Result: "Alice"Path Syntax
Pipe a list path to a target structure. Path elements are applied sequentially:
- Strings navigate dict fields
- Numbers index into lists
- Empty path returns target unchanged
Dict Path
["address", "city"] -> [address: dict[street: "Main", city: "Boston"]]
# Result: "Boston"List Path
[0, 1] -> list[list[1, 2, 3], list[4, 5, 6]]
# Result: 2 (first list, second element)Mixed Path
["users", 0, "name"] -> [users: list[dict[name: "Alice"], dict[name: "Bob"]]]
# Result: "Alice"Empty Path
[] -> [name: "test"]
# Result: dict[name: "test"]Error Handling
["missing"] -> [name: "test"] # Error: key 'missing' not found
[5] -> list[1, 2, 3] # Error: RILL-R009See Reference for full dispatch semantics including dict dispatch, list dispatch, and default values.
Status Probe (.!, .!field)
Bare .! tests whether a value is invalid (halted). .!field projects a named field of the status sidecar.
$result.! # bool: true if $result is invalid, false if valid
$result.!code # atom, a member of union(#ok, error_code) (#ok when valid)
$result.!message # string message| Form | Returns |
|---|---|
$v.! | bool — false when valid, true when invalid |
$v.!code | atom, a member of union(#ok, error_code) (#ok when valid). .!code.^type reports union(error_code, #ok); .!code.^effective reports atom |
$v.!message | string status message |
$v.!provider | string provider tag |
$v.!trace | list of trace-frame dicts |
$v.!<other> | provider-specific raw field; missing keys yield "" |
Compare with existence probes: .? tests presence (returns bool). .! bare also returns bool; field projections (.!code, .!message, …) return the projected value’s type. See Error Handling for guard and invalid value patterns.
Default Operator ??
Provide a default value if field is missing or access fails:
[:] => $empty
$empty.name ?? "unknown" # "unknown"
[name: "alice"] => $user
$user.name ?? "unknown" # "alice"
$user.age ?? 0 # 0With Function Calls
The default operator works with any expression, including function and method calls:
get_data().status ?? "default" # "default" if status field missing
fetch_value() ?? "fallback" # "fallback" if fetch_value returns undefinedWith Method Calls
The ?? operator applies after method invocations in access chains:
$dict.transform() ?? "default" # default if method throws or result missing
$obj.compute().value ?? 0 # default if value field missing after method
$config.get_setting() ?? [:] # default if method returns undefinedMethod calls evaluate fully before the default operator applies.
?? recovers only a miss on the last step of an access chain, for fields, annotations, and brackets. $d.x.y ?? 0 with .x missing halts RILL-R009, as do $d.b[1] ?? 0 with .b missing and $d[$d.zz] ?? 0 with .zz missing. An existence check is the right-most step too, so $d.x.?b ?? 0 with .x missing halts RILL-R009. A wrong key type on a list, tuple, or ordered receiver halts RILL-R002; a non-string selector on a dict or stream halts #TYPE_MISMATCH (see Dict Keys Are Strings).
Existence Operators
Presence Probe .?
.? on a bare value (no field name) returns true when the current $ is a valid (non-halted) value.
$result.? # true if $result is valid, false if invalid
$value -> .? # bool: present and valid?Use .? after guard to branch on success vs. invalid result. The status probe .!code retrieves the specific code when .? returns false.
Field Existence .?field
Returns boolean:
[name: "alice"] => $user
$user.?name # true
$user.?age # falseVariable Existence .?$k
.?$k selects as [$k] does, so it is the probe of $c.$k and agrees with .?[$k]. Only a miss, an absent key or an out-of-range index, yields false.
list[1, 2] => $l
5 => $k
$l.?$k
# Result: falseA string held in $k is a key, not a field name. On a list, tuple, string, number, atom, function, iterator, or type value it halts with the error the bracket read raises, such as List index must be number, got string. ?? does not recover it, so $l.$k ?? "d" with $k holding "a" halts too. Spell a field name to probe it as one: $user.?name.
Existence with Type .?field&type
Check existence AND type:
[name: "alice", age: 30] => $user
$user.?name&string # true
$user.?age&number # true
$user.?age&string # falseThe &type position accepts parameterized types and union types.
Parameterized type:
[items: [1, 2, 3]] => $items_data
$items_data.?items&list(number)
# Result: trueDict structural type:
[cfg: [key: "x"]] => $cfg_data
$cfg_data.?cfg&dict(key: string)
# Result: trueUnion type:
[score: 42] => $score_data
$score_data.?score&union(string, number)
# Result: trueType Operators
Type Assert :type
Error if type doesn’t match, returns value unchanged:
42:number # 42
"hello" -> :string # "hello"Structural type syntax is supported in assertions. The structural form specifies element or field types:
[1, 2, 3] -> :list(number) # passes: all elements are number
[a: 1, b: 2] -> :dict(a: number, b: number) # passes: fields match types
[1, "x"] -> :list(number) # ERROR: structural type mismatch
[a: 1, b: 2] -> :dict(a: number) # ERROR: extra field, see Type SystemSee Extra and Missing Dict Fields for the exactness table.
"hello" -> :number # ERROR: expected number, got stringType Check :?type
Returns boolean:
42:?number # true
"hello":?number # false
"hello" -> :?string # trueCoarse checks return boolean directly:
[1, 2, 3] -> :?list # true
[a: 1] -> :?dict # trueStructural checks are also supported. These match element and field types:
[1, 2, 3] -> :?list(number) # true
[1, "x"] -> :?list(number) # false
[a: 1] -> :?dict(a: number) # true^type Operator
^type returns the structural RillTypeValue for a value. The type value carries both a coarse name and a full structural description:
[1, 2, 3] -> ^type # list(number)
[a: 1, b: "x"] -> ^type # dict(a: number, b: string)
42 -> ^type # numberThe type value formats as a structural string via -> string or string interpolation:
[1, 2, 3] -> ^type -> string # "list(number)"
"hello {[1,2,3] -> ^type}" # "hello list(number)"To get the type name only, chain .name on the type value:
[1, 2, 3] -> ^type -> .name # "list"
42 -> ^type -> .name # "number".^type on a variable reports the declared type when one is carried, else the own type. .^effective always reports the own type:
42 => $x:union(string, number)
$x.^effective.signature
# Result: "number"See Types for detailed type system documentation.
Conversion Operator -> type
The -> type operator converts a value to the target type. Same-type conversions are no-ops. Incompatible conversions halt with RILL-R036.
| Source | -> list | -> dict | -> tuple | -> ordered(sig) | -> number | -> string | -> bool |
|---|---|---|---|---|---|---|---|
list | no-op | error | valid | error | error | valid¹ | error |
dict | error | no-op | error | valid | error | valid¹ | error |
tuple | valid | error | no-op | error | error | valid¹ | error |
ordered | error | valid | error | no-op | error | valid¹ | error |
string | error | error | error | error | valid² | no-op | valid³ |
number | error | error | error | error | no-op | valid¹ | valid⁵ |
bool | error | error | error | error | valid⁴ | valid¹ | no-op |
¹ Uses formatValue semantics for formatted output.
² Parseable strings only; halts with RILL-R038 on failure.
³ Accepts only "true" and "false"; halts with RILL-R036 otherwise.
⁴ true maps to 1, false maps to 0.
⁵ 0 maps to false, 1 maps to true; all other values halt with RILL-R036.
A function, an iterator, or a vector has no -> string conversion, and neither has a list, dict, tuple, or ordered that holds one at any depth. Converting one, interpolating one in a string, or joining one with .join halts with RILL-R036. A datetime or a duration interpolates as its printed form, and duration -> string yields that form, but -> string on a datetime, or on a collection that holds a datetime or a duration, halts with RILL-R036.
-> list(T), -> dict(...), -> ordered(...), and -> tuple(...) convert every element, field, and position and halt RILL-R036 or RILL-R038 naming the part; see the conversion table.
-> map(string, V) converts a dict, and -> dict converts a string-keyed map; every other source halts RILL-R036. See Map Conversion.
-> union(...) returns a member unchanged and halts RILL-R036 otherwise; see Conversion into a Union.
Structural conversion with signatures: -> dict(sig), -> ordered(sig), and -> tuple(sig) accept a structural type signature as the conversion target. The source value must match the target kind (dict-to-dict, tuple-to-tuple, or list-to-tuple). Fields present in the signature but absent from the source are hydrated with the signature’s default values. See Type System for structural type and default value documentation.
Spread Call Operator
The spread call operator expands a value into the positional or named arguments of a function call. Spreading is opt-in; passing a tuple or ordered value without ... passes it as a single argument.
Syntax Forms
| Form | Description |
|---|---|
$fn(...) | Spread piped value into call arguments |
$fn(...$expr) | Spread a specific expression into call arguments |
$fn(a, ...$rest) | Mix fixed args with a spread |
... (bare) is equivalent to ...$; it spreads the current piped value.
At most one spread is permitted per call.
Piped Spread
Spread the piped value into a multi-param function:
fn(a, b, c) { "{$a}-{$b}-{$c}" } => $fmt
tuple[1, 2, 3] -> $fmt(...)
# Result: "1-2-3"Variable Spread
Spread a stored value directly:
fn(a, b) { $a + $b } => $add
tuple[3, 4] => $args
$add(...$args)
# Result: 7Mixed Args
Combine fixed arguments with a spread:
fn(a, b, c) { "{$a}-{$b}-{$c}" } => $fmt
tuple[2, 3] => $rest
$fmt(1, ...$rest)
# Result: "1-2-3"No Spread (Pass-Through)
Without ..., a tuple passes as a single argument:
fn(t) { $t } => $passthrough
tuple[1, 2, 3] -> $passthrough()
# Result: tuple[1, 2, 3]Operator Precedence
From highest to lowest:
- Member access:
.field,[index] - Type operators:
:type,:?type - Unary:
-,! - Multiplicative:
*,/,% - Additive:
+,- - Comparison:
==,!=,<,>,<=,>= - Logical AND:
&& - Logical OR:
|| - Default:
?? - Pipe:
-> - Capture:
=>
Use parentheses to override precedence:
(2 + 3) * 4 # 20
5 -> ($ > 3) ? "big" ! "small" # "big"Operator-Level Annotations
The ^(limit: N) form is not part of the current parser surface. The parser emits RILL-R081 (migration error) for any occurrence of ^(limit: in expression position. The examples below show the rejected syntax for reference only.
Rejected syntax (RILL-R081):
# Error: RILL-R081 — Migration error: use `do(limit: N) { body }` at 1:N
[1, 2, 3] -> seq(^(limit: 1000) { $ * 2 })# Error: RILL-R081 — Migration error: use `do(limit: N) { body }` at 1:N
[1, 2, 3] -> fan(^(limit: 10) { $ + 1 })# Error: RILL-R081 — Migration error: use `do(limit: N) { body }` at 1:N
[1, 2, 3, 4] -> filter(^(limit: 50) { $ > 2 })# Error: RILL-R081 — Migration error: use `do(limit: N) { body }` at 1:N
[1, 2, 3] -> fold(0, ^(limit: 20) fn(x) { $@ + $x })Iteration limits are controlled via the do(limit: N) loop construct, not via operator-level annotation. See Control Flow for do(limit: N) syntax. The angle-bracket form do<limit: N> is a parse error (RILL-P025).
See Also
- Types: Type system and assertions
- Variables: Capture and scope
- Control Flow: Conditionals and loops
- Collections: Collection operators
- Reference: Quick reference tables