Renderingla

nexum

Marks a class member as bound to the current instance.

Syntax: nexum <type> <name> [= <expression>]

Category

type

Related

Examples

examples/corpus/nexum/nexum.fab (canonical · keyword)

Marks a class member as bound to the current instance.

# nexum — bound genus field (compile-time constant)
#
# nexum <typus> <nomen> = <expressio>
#
# GRAMMAR:
#   boundField :← 'nexum' type ident '=' expr
#
# EXPECTED OUTPUT:
#   nexum.expected — bound field value 7 via accipe().

genus Computator {
    # bound field — same value for every instance
    nexum numerus valor = 0

    functio accipe() → numerus {
        redde ego.valor
    }
}

incipit {
    # instance overrides bound default
    fixum _ c ← Computator { valor = 7 }
    nota c.accipe()
}

Expected output:

7