Every reserved word in SCUA, with a one-line meaning and a pointer to
the page that covers it. A few of these (state,
on, ask, tell, path,
wait_for) are contextual: they only act as keywords in the
right position, and stay usable as ordinary names elsewhere.
#Index
Jump straight to a keyword, or browse the groups below.
and · as · ask · break · comptime · const · continue · contract · debug · do · else · elseif · end · enum · false · flags · fn · for · gate · gated · if · import · in · info · interface · let · match · matches · migrate · nil · not · on · or · partition · path · record · rescue · return · select · severe · spawn · state · tell · then · trace · true · try · type · wait_for · warn · when · where · while
#Declarations
| Keyword | Meaning |
|---|---|
let |
Declare a reassignable binding: let x = … (or
let x: T = …). See Variables. |
const |
Declare an immutable binding. Reassigning it is a compile error. See Variables. |
fn |
Declare a function fn name(params) … end, or a function
value fn(params) … end. See Functions. |
record |
Declare a record type with a fixed set of fields:
record Name { field: T, … }. See Records and gradual types. |
interface |
Declare a structural interface — a set of required methods:
interface Name { fn m(self, …) -> T … }. A type
satisfies it just by having those methods, with nothing to declare on
the type. See Objects and OOP
patterns. |
type |
Declare a type alias: type Name = T. See Records and gradual types. |
enum |
Declare a closed set of named variants:
enum Name { A, B }. A match over it is checked
for exhaustiveness. See Enums. |
flags |
Declare a typed bit-set: flags Name { A, B, C }.
Combine with |/&/^, test with
in, remove with .without(...). See Flags. |
contract |
Declare named boolean clauses that refine a value:
contract Name(p) label: predicate else "reason" end. See
Contracts. |
import |
Load a module and bind its exports to a name:
import name. See Modules. |
as |
Rename an import: import name as alias. See Modules. |
migrate |
Declare how older saved data upgrades to the current record shape:
migrate Rec(old) … end. See Save, load, and
migrate. |
gate |
Declare a named set of audiences
allowed to see a field:
gate Name { Audience.A, Audience.B }. Mark fields with
gated, then build a view with project. See Audience gates. |
#Control flow
| Keyword | Meaning |
|---|---|
if / then / elseif /
else |
Conditional:
if cond then … elseif cond then … else … end. See Control flow. |
while |
Loop while a condition holds: while cond do … end. See
Control flow. |
for / in |
Iterate a collection or range: for v in xs do … end.
in separates the loop variables from the iterable. See Control flow. |
do |
Open a block: it closes a while/for
header, or stands alone as a scoped do … end. |
end |
Close a block (fn, if, while,
for, do, match, try,
record, partition, and the rest). |
return |
Return a value from a function, or reply from an ask
handler. |
break |
Exit the nearest enclosing loop. |
There is also continue, which skips to the next
iteration of the nearest loop. See Control flow.
#Pattern matching
| Keyword | Meaning |
|---|---|
match |
Test a value against patterns:
match subject Tag(x) -> … _ -> … end. See Pattern matching. |
when |
A guard on a match arm: pattern when cond -> … takes
the arm only if cond is also true. See Pattern matching. |
#Errors
| Keyword | Meaning |
|---|---|
try |
Run a body, catching any fault: try … rescue e … end.
See Errors and faults. |
rescue |
The handler clause of a try. It runs when the body
faults, binding the error to a name. See Errors and faults. |
#Types and refinement
| Keyword | Meaning |
|---|---|
where |
Attach a refinement to a record or field:
… where <predicate> [else "reason"], or reuse a
contract with where Contract. Checked when a value is
constructed. See Contracts. |
matches |
A boolean test: x matches Contract is true when
x satisfies the contract. See Contracts. |
gated |
Mark a record field as visible only to a gate's audiences:
field: T gated GateName. Ungated fields are open to all.
See Audience gates. |
#Partitions and messaging
| Keyword | Meaning |
|---|---|
partition |
A self-contained unit of private state and behaviour, reachable only by message. See Partitions and the actor model. |
state |
Inside a partition, declares a private, persistent state field. |
on |
A tell-handler: on Tag(args) … end runs asynchronously
with no reply. |
ask |
As a handler, ask Tag(args) … end replies via
return. As an expression, ask e.Tag(args)
sends a request and waits for the reply. |
tell |
Send a fire-and-forget message: tell e.Tag(args). |
#Concurrency
| Keyword | Meaning |
|---|---|
spawn |
Start a background task that runs concurrently:
spawn do … end. See Concurrency and time. |
wait_for |
Selective receive: wait_for(Tag) suspends until a
message of that tag arrives and evaluates to its payload. See Concurrency and time. |
select |
Wait on several message views at once and run the first ready arm:
select wait_for(Tag) -> … wait(d) -> … default -> … end.
See Concurrency and time. |
#Logging
Each of these emits a log record at one level:
level(message[, fields]). They are ordered from most to
least verbose, and levels below the active floor are stripped at compile
time. severe records a serious error but, unlike a fault,
does not raise or unwind. See Logging.
trace, debug, info,
warn, severe
#Conditional compilation
| Keyword | Meaning |
|---|---|
comptime |
A compile-time conditional:
comptime if build.flag then … end. The condition is
evaluated against the host's build config, and only the selected branch
is checked and emitted. See Conditional
compilation. |
#Operators spelled as words
| Keyword | Meaning |
|---|---|
and |
Short-circuiting logical AND. It evaluates to one of its operands, not necessarily a bool. See Operators. |
or |
Short-circuiting logical OR. It also evaluates to an operand. See Operators. |
not |
Logical negation, always a bool. See Operators. |
in |
Membership test, and the separator in a for loop. See
Operators. |
matches |
Contract test (above). |
#Literals
| Keyword | Meaning |
|---|---|
true / false |
The two booleans. |
nil |
The absence of a value. |
path |
A first-class path literal: path"a/b/c", a reusable
value for reaching into nested data with
get/set or the @ operator. See the path operator. |