Marks a class member as belonging to the type itself.
Syntax: generis <type> <name> [= <expression>]
Category
type
Related
Examples
examples/corpus/generis/generis.fab (canonical · keyword)
Marks a class member as belonging to the type itself.
# generis marks a static genus field (shared across instances)
#
# generis <type> <field> = <initium> -- class-level binding, not per-instance
#
# GRAMMAR:
# fieldDecl inside genusDecl :← 'generis'? type ident ('=' expr)?
#
# EXPECTED OUTPUT:
# ruber
#
# Instance field `nomen` is per-object; `generis ruber` would be accessed on the
# genus type in full programs (here only instance fields are read).
genus Color {
generis textus ruber = "#ff0000"
textus nomen = "ruber"
}
incipit {
fixum _ color ← Color {}
nota color.nomen
}Expected output:
ruber