value, object, contract, and enum, plus the visibility modifiers and construction forms that go with them.
Visibility modifiers
All declaration keywords accept a visibility modifier prefix.
value
Declares an immutable, identity-free type.
Syntax
- Value members must be value-like.
- Members are immutable by default.
- No
initblock; values are assembled with a field block. - May declare instance methods,
type funcs, and conform to contracts.
object
Declares an identity-bearing type.
Syntax
- Members are immutable by default; use
varfor mutable members. - Required immutable members must be assigned in
init. - Exactly one primary
initin v0.1; no constructor overloading. - May declare instance methods,
type funcs, and conform to contracts.
contract
Declares a capability contract that types can conform to.
Syntax
- Contracts declare requirements only. No stored fields, no
init, no method bodies, notype func. - May require methods, read-only properties, and read-write properties.
- May be generic and may declare contract constraints on type parameters.
- Enum conformance, default implementations, and generic contract conformance are deferred.
Contract conformance
Declares that avalue or object satisfies one or more contracts.
Syntax
- Conformance is always explicit.
- Forge verifies every required member is present with a matching signature.
- Each contract in the list must resolve to a contract type.
enum
Declares a finite, named set of cases.
Syntax
- Case names must be unique within the enum.
- Enum cases are PascalCase.
- Case payloads (associated values) are deferred in v0.1.
matchon enum cases follows the exhaustiveness rules described in Operators.
Members
Member field
var.
Computed property
get is required for readable properties. set accepts a single value parameter matching the property type. Kairo does not auto-generate getters or setters in v0.1.
Construction
Value construction
Object construction
Related
Types (language guide)
The value/object model in prose.
Command Catalog
Every construct in a scannable table.
