OxL Reference

kw interface

Reserved keyword

The list of words: §1.4

Syntax

ebnf
Interface   = "interface" Ident [ Generics ] "{" { IMember } "}" ;

Grammar: App. A

Defined in

Examples

oxl
pub(api) interface Storage {
  fn get(k: str) -> bytes?  io
  var fn put(k: str, v: bytes)  io
  fn has(k: str) -> bool  io => get(k) != none     // a default method
}

interface ReadWrite { embed Reader; embed Writer }
interface Container<T> { type Item = T; fn items() -> iter<T> }

@explicit interface Persistent { fn key() -> str }

assert FileStorage: Storage                      // static check

— 4.6 Interfaces

oxl
impl Money {
  pub const ZERO: Money = Money{ minor: 0 }
  pub const MAX_TRANSFER: Money = Money.rub(1_000_000)
}

interface Codec<T> { const NAME: str }          // the implementation must supply a value
impl Codec<Point> for GeoHashCodec { const NAME: str = "geohash" }

— 4.5 impl and methods

Related diagnostics

explicit-interface, interface-not-satisfied, impl-foreign-type, unknown-method, unknown-type, schema-attr, attribute-not-applicable, cache-not-readonly, invalid-window, retry-not-idempotent, rpc-attr

See also