kw is
Reserved keyword
The list of words: §1.4
Syntax
Postfix = Primary { "(" [ Args ] ")" [ TrailingBlock ] | "[" Expr "]" | "." ( Ident | IntLit | "[" Expr "]" )
| "?." Ident | "?" | "!" | "as" Type | "is" Type } ;Grammar: App. A
Defined in
- 5.4 Conditions — There is no ternary operator.
- 5.2 Precedence and associativity — Precedence and associativity
- 3.5 Unions and optionals — A | B — an anonymous union.
- 13.4 Authorisation and policies — The subject of a policy
- 1.4 Keywords — Reserved (cannot be used as names)
- 5.3 Overloading and user-defined operators — Overloading built-in operators — op declarations in impl
- 6.5 Errors — There are no exceptions.
- 18.2 Assertions and fixtures — assert expr is executed in all profiles, including prod (profiles switch off only contracts, §6.7, and the output of dbg, §2.2); on failure
Examples
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 Receiptpolicy Orders {
allow get(id) if caller.isUser(db.find(Order, id)?.userId)
allow list, recent if caller.has(role: .Support)
allow * if caller.service("billing")
deny delete unless caller.has(role: .Admin) && caller is .User(mfa: true, ..)
}
@public rpc health() -> Ok
@allow(role: .Admin) rpc purge() -> Ok
@internal rpc create(…) -> Order— 13.4 Authorisation and policies
Related diagnostics
chained-comparison, type-mismatch, data-rights, missing-policy, unknown-policy-target, not-callable, not-overloadable, operator-decl, range-not-iterable, fail-type, question-context, unhandled-error, fixture-yield