✓
Passing This code compiles and runs correctly.
Code
// A store-view is the projection join. `new(Player)` / `new(Enemy)` pack
// each proto at that store's root (seed names the proto; leaves keep proto
// field names — `str`, not `Player.str`). The view lists the stores; that
// list is the kind vocabulary. Projection is (path-from-that-root, type):
// `str: Strength` meets across the view. `mana` / `armor` stay private.
// Insert and obligations stay on the logical store. Query/stripe of the
// view is where `e is Player` means anything. A view is not a container —
// no capacity, no allocation, no insert; the rows live in the member
// stores. A store in no view keeps its own layout (285/286).
import std/io
import std/proto
import std/store
std/proto:i64(Strength)
std/proto:i64(Mana)
std/proto:i64(Armor)
std/proto(Player) {
str: Strength
mana: Mana
}
std/proto(Enemy) {
str: Strength
armor: Armor
}
std/store:new(Player, capacity: 8) { Player }
std/store:new(Enemy, capacity: 8) { Enemy }
std/store:view(Entities) {
Player
Enemy
}
std/store:insert(Player) { str: 18, mana: 12 }
std/store:insert(Enemy) { str: 10, armor: 5 }
std/store:query(Entities)
! query e |> std/io:print.ln("entity {{ e.str:d }}")
std/store:query(Entities)
! query e when e is Player |> std/io:print.ln("player {{ e.str:d }} {{ e.mana:d }}")
std/store:query(Entities)
! query e when e is Enemy |> std/io:print.ln("enemy {{ e.str:d }} {{ e.armor:d }}")
Actual
entity 18
entity 10
player 18 12
enemy 10 5
Expected output
entity 18
entity 10
player 18 12
enemy 10 5
Flows
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Strength)
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Mana)
flow ~i64 click a branch to expand · @labels scroll to their anchor
i64 (expr: Armor)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Player, source: str: Strength
mana: Mana)
flow ~std/proto click a branch to expand · @labels scroll to their anchor
std/proto (Enemy, source: str: Strength
armor: Armor)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Player, capacity: 8, source: Player)
flow ~new click a branch to expand · @labels scroll to their anchor
new (Enemy, capacity: 8, source: Enemy)
flow ~view click a branch to expand · @labels scroll to their anchor
view (Entities, source: Player
Enemy)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (Player, source: str: 18, mana: 12)
flow ~insert click a branch to expand · @labels scroll to their anchor
insert (Enemy, source: str: 10, armor: 5)
flow ~query click a branch to expand · @labels scroll to their anchor
query (Entities)
flow ~query click a branch to expand · @labels scroll to their anchor
query (Entities)
flow ~query click a branch to expand · @labels scroll to their anchor
query (Entities)
Test Configuration
MUST_RUN