kw else
Reserved keyword
The list of words: §1.4
Syntax
ClusterClause = "seeds" Expr | "port" IntLit | "trace_sample" FloatLit | "auth" Block | "defaults" "{" { Ident Expr } "}"
| "role" Ident "{" RoleClause { ( ";" | NL ) RoleClause } "}"
| "assign" "by" Expr { "else" Expr } ;If = "if" ( Expr | "let" Pattern "=" Expr ) Block [ "else" ( If | Block ) ] ;SelArm = ( "recv" Pattern "from" Expr | "send" Expr "to" Expr | "after" Expr | "else" ) "=>" Expr ;Grammar: App. A
Defined in
- 8.7 Channels and select — tx.send(x) suspends when the buffer is full; cap
- 5.4 Conditions — There is no ternary operator.
- 1.2 Statement termination — A statement is terminated by ; or by a line break.
- 12.1 Cluster declaration — A program has at most one cluster.
- 1.4 Keywords — Reserved (cannot be used as names)
- 4.8 Generics — Parameters: type parameters T, constant parameters const N
- 14.2 Dynamic configuration — dynamic Name { …
Examples
let (tx, rx) = chan<Job>(cap: JOB_QUEUE)
select {
recv job from rx => process(job)
send r to results => sent += 1
after IDLE_TIMEOUT => log.info("idle")
else => tick() // non-blocking variant
}let kind = if n < 0 { "neg" } else if n == 0 { "zero" } else { "pos" }
if let User{ role: .Admin, name, .. } = u { greet(name) }
if x is Receipt { save(x) } // x is narrowed to ReceiptRelated diagnostics
actor-not-hosted, cluster-auth, cluster-decl, cluster-needs, cluster-seeds, placement-conflict, saga-without-role, service-not-served, topic-without-journal, unknown-role, bound-not-satisfied, generic-args