A type owns typed fields and methods. A trait describes methods a value must
provide. Neither schedules work: attach a type value to an entity and use a
system when it needs to run over time.
Make a type value
The fixture prints 4 and then Some(9): it constructs a nominal type value,
then reads a list through an explicit optional value.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
type Name { field: T; func method() -> T { ... } } declares a nominal record.
Fields may have defaults. A constructor may omit a defaulted field, but must
supply every field without a default; unknown fields and incompatible values
are compile errors. Two types with the same fields still have different types.
Fields are public.
Methods use the implicit self receiver; do not list it as a parameter. A
method that changes self needs a receiver rooted in a mutable binding. The
compiler checks every type and method body, including unused ones.
State a behavior contract
trait Readable { func read() -> f32; } states a callable contract.
impl Readable for Gauge must provide every required method with exactly that
signature. A trait-typed value exposes the trait methods, not arbitrary fields
of its implementing type. Type inheritance, associated types, generic bounds,
and derivation are not implemented.
Store and pass functions
Write a function type as func(f32) -> f32. A function value can be assigned
to a binding, passed to another function, returned, or stored in a typed list
or type field. Calls check the same signature in every position.
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
Reading a nonmutating method as a value captures a copy of its receiver.
Capturing a method that mutates an ordinary type is rejected: use
bind[T](entity).method for a callback that
updates an entity’s live component.
Specialize ECS helpers
Choose the component type before storing an ECS helper: get[Counter] is a
function value; get[Counter](entity) calls it immediately. The same rule applies
to has, query, and bind.
| Value | Function type |
|---|---|
get[Counter] | func(Entity) -> Counter |
has[Counter] | func(Entity) -> Bool |
query[Counter] | func() -> List[Entity] |
bind[Counter] | func(Entity) -> ComponentReference[Counter] |
Show a QR code for your glasses, or send a link to another browser. You can keep working here.
Sharing starts a fresh run of the last compiled code. Your editor draft stays here.
Join a session
Open an invitation link, or paste a link or code from the other device.
On RayNeo, open Menu → Connect live and scan this code. In another browser, open the invitation link below.
Or enter this code:
Waiting for another device. You can keep working while it connects.
Browsers can edit code; every device can use scene controls. The device that started the session controls playback.
Connection settings
A full invitation link includes its host. With a code alone, both devices need the same live host. Pairing setup
No output.
- Executed source spans appear here.
ComponentReference[Counter] stores an entity/component identity; calling its
bound methods resolves the current component. Function parameters, return
values, and fields use explicit types; local bindings infer a fixed type from
their initializer. Imported type identity is nominal: models.Point is
distinct from a local Point.