OxL Reference

kw if

Reserved keyword — policy (§13.4)

The list of words: §1.4

Syntax

ebnf
Rule        = ( "allow" | "deny" ) ( "*" | RTarget { "," RTarget } ) ( "if" | "unless" ) Expr ;
ebnf
MockArm     = Ident "(" [ Patterns ] ")" [ "if" Expr ] "=>" MockSeq ;
ebnf
If          = "if" ( Expr | "let" Pattern "=" Expr ) Block [ "else" ( If | Block ) ] ;
ebnf
Match       = "match" Expr "{" { Pattern [ "if" Expr ] "=>" Expr ( "," | NL ) } "}" ;

Grammar: App. A

Defined in

Examples

oxl
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 Receipt

— 5.4 Conditions

oxl
dynamic Limits {
  rps: u32 = DEFAULT_RPS
  newSearch: Flag = Flag.off
}

let l = Limits.get()
if current > l.rps.get() { throttle() }
for await v in l.rps.changes() { limiter.set(v) }
if l.newSearch.on(for: ctx.caller) { newSearch(q) } else { oldSearch(q) }

— 14.2 Dynamic configuration

Related diagnostics

bad-init, missing-field, must-close, positional-literal, sealed-literal, fail-type, question-context, unhandled-error, type-mismatch, not-assignable, data-rights, missing-policy, unknown-policy-target

See also