kw static
Reserved keyword
The list of words: §1.4
Syntax
Receiver = [ "var" | "move" | "static" ] ;Static = "static" Ident ":" Type "=" Expr ;Grammar: App. A
Defined in
- 5.3 Overloading and user-defined operators — Overloading built-in operators — op declarations in impl
- 9.5 User-defined serialisers — Level 1 — representation through another type (Repr), acts in all formats and in schemas
- 4.1 Variables and constants — There are no mutable globals without sync.
- 4.5 impl and methods — Inside a method self and Self are available.
- 8.9 Software transactional memory — atomic { … } executes the body as a serialisable transaction over TVars.
- 12.1 Cluster declaration — A program has at most one cluster.
- 1.4 Keywords — Reserved (cannot be used as names)
Examples
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
@repr(i64)
data Money { minor: i64 }
impl Repr<i64> for Money {
fn toRepr() -> i64 => minor
static fn fromRepr(v: i64) -> Money | DecodeError => Money{ minor: v }
}— 9.5 User-defined serialisers
Related diagnostics
not-callable, not-overloadable, operator-decl, range-not-iterable, schema-attr, global-mutable, mutate-immutable, impl-foreign-type, unknown-method, atomic-effects, actor-not-hosted, cluster-auth, cluster-decl, cluster-needs