static
Translation status: English reader-locale proof. Term names and code fences follow the en pack; supporting prose may still be English.
Marks a class member as belonging to the type itself.
Syntax: static <type> <name> [= <expression>]
Category#
type
Related#
Examples#
radix/corpus/generis/generis.fab (canonical · keyword)#
Marks a class member as belonging to the type itself.
# =============================================================================
# static — Marks a class member as belonging to the type itself
# =============================================================================
#
# What this teaches:
# • Marks a class member as belonging to the type itself.
# • Related keywords: class, ego
#
# Common mistakes:
# • Accessing a `static` field on an instance instead of the type — `static` fields are static members accessed via the class name, not via `ego`.
#
# See also: class, ego
# =============================================================================
# static marks a static class field (shared across instances)
#
# static <type> <field> = <initium> -- class-level binding, not per-instance
#
# GRAMMAR:
# fieldDecl inside genusDecl :← 'static'? type ident ('=' expr)?
#
# EXPECTED OUTPUT:
# ruber
#
# Instance field `name` is per-object; `static ruber` would be accessed on the
# class type in full programs (here only instance fields are read).
class Color {
static string ruber = "#ff0000"
var string name = "ruber"
}
main {
const Color color ← Color {}
print color.nomen
}Expected output:
ruber