Types and Inheritance
User-defined types are declared with type ... struct.
type Counter struct { value i32
fn reset() { this.value = 0 }}Current runtime model
Section titled “Current runtime model”type ... struct is currently class-backed syntax in the runtime. Treat it as
the user-facing way to define object-shaped types today, not as a value-type
system.
Fields and methods
Section titled “Fields and methods”Fields live directly in the type body. Methods use the same fn syntax as
top-level functions.
type Box struct { value i32
fn get() i32 { return this.value }
fn set(v i32) i32 { this.value = v return this.value }}Use this inside methods to read or write the receiver.
Construction
Section titled “Construction”Construction uses normal call syntax on the type name:
var counter = Counter()var box Box = Box()Type aliases
Section titled “Type aliases”The language also supports aliases:
type Score i32Aliases are part of the documented language surface in the README even though most examples in the repo focus on structs.
Inheritance
Section titled “Inheritance”Single inheritance is available with < Parent.
type A struct { fn greet() str { return "A" }}
type B struct < A { fn greet() str { return super.greet() + "B" }}Use super.method() to call an inherited implementation.
Operator annotations
Section titled “Operator annotations”The compiler also supports operator annotations on methods. This is currently a real feature, but it is still narrower than a full custom-operator system.
Supported annotations today are limited to:
+-*/==!=<<=>>=