OxL Reference

kw as

Reserved keyword

The list of words: §1.4

Syntax

ebnf
Import      = ( Ident | OpSymbol ) [ "as" Ident ] ;
ebnf
Env         = Expr [ "as" Ident ] ;
ebnf
Postfix     = Primary { "(" [ Args ] ")" [ TrailingBlock ] | "[" Expr "]" | "." ( Ident | IntLit | "[" Expr "]" )
            | "?." Ident | "?" | "!" | "as" Type | "is" Type } ;

Grammar: App. A

Defined in

Examples

oxl
impl Vec3 {
  static op +(a: Vec3, b: Vec3) -> Vec3 => Vec3(a.x + b.x, a.y + b.y, a.z + b.z)
  static op *(v: Vec3, k: f32) -> Vec3 => Vec3(v.x * k, v.y * k, v.z * k)
  static op -(v: Vec3) -> Vec3 => v * -1.0
  op [](i: usize) -> f32 { … }            // read by index
  var op [](i: usize) -> &var f32 { … }   // write by index
  op ()(t: f32) -> Vec3 { … }             // call as a function
  static op <=>(a: Vec3, b: Vec3) -> Ordering { … }
  op as Vec4 => Vec4(x, y, z, 1.0)
}

— 5.3 Overloading and user-defined operators

oxl
use std.time { Duration, now }
use std.http.{Client as Http}
use self.billing { charge }      // a module of one's own package
use super.common { Money }       // the parent module
use auth.tokens { verify }       // a dependency from oxl.toml
use parsers { <|> }              // importing an operator
use std.coll.*                   // all pub names (a warning in libraries)

— 2.2 Import

Related diagnostics

not-callable, not-overloadable, operator-decl, range-not-iterable, chained-comparison, bad-import-root, glob-import, import-conflict, unresolved-import, unresolved-name, cluster-auth, fixture-yield

See also