OxL Reference

kw result

Contextual keyword — function contracts (§6.7)

The list of words: §1.4

Defined in

  • 1.4 Keywords — Reserved (cannot be used as names)
  • 6.7 Contracts — requires is checked on entry, ensures on exit (result is the return value, old(e) is the value of e on entry), invariant (§4.2) — after cons
  • 5.5 Pattern matching — A match MUST be exhaustive.
  • 5.6 Loops — for accepts Iterable<T> (including iter<T>, collections, ranges); for await accepts Streamable<T>.
  • 16.3 gRPC and protobuf — import proto "payments.proto" generates an extern service and types; calls are as to ordinary services through connect.

Examples

oxl
match result {
  Receipt r if r.amount > LIMIT => review(r)
  Receipt r                     => ok(r)
  Declined(reason)              => warn(reason)
  Timeout | Unavailable         => retryLater()
  _                             => fail Unknown
}

— 5.5 Pattern matching

oxl
for u in users { … }
for (i, u) in users.enumerate() { … }
for i in 0..n where i % 2 == 0 { … }      // filter
for await msg in input { … }               // stream<T>
while cond { … }
while let x? = queue.pop() { … }
loop { if done { break result } }          // loop is an expression
'outer: for a in xs { for b in ys { if a == b { break 'outer } } }

— 5.6 Loops

Related diagnostics

contract, non-exhaustive, pattern-bindings, unreachable-arm, break-value, outside-loop, import-skip

See also