ecs/refined-world
src/ecs/refined-world.tur
an aliveness-refined world facade (RE1 / gap C2).
Since: RE1 2026-07-26; :sealed 2026-07-29
defopaque
RGWorld
(RGWorld)
defn
rgworld-new
(rgworld-new :)
defn
rgworld-spawn!
(rgworld-spawn! [^unique ^mut w : RGWorld x0 : int] :)
defn
rgworld-despawn!
(rgworld-despawn! [^unique ^mut w : RGWorld e : Entity] :)
defn
rgworld-alive?
(rgworld-alive? [^borrow w : RGWorld e : Entity])
defn
rgworld-get-x!
(rgworld-get-x! [^borrow w : RGWorld e : #refine{ x : Entity | (rgworld-alive? w x) }] :)
defn
rgworld-set-x!
(rgworld-set-x! [^unique ^mut w : RGWorld e : Entity v : int] :)
defn
rgworld-ent-at
(rgworld-ent-at [i : int] :)
the first-generation entity candidate for slot i.
Parameters
| i | slot index |
Returns
The Entity (slot i, generation 0).
Example
(rgworld-alive? w (rgworld-ent-at 0))
Since: RE1 2026-07-26
defmacro
for-each-alive!
(for-each-alive! [w n binder & body])
run body for each still-alive entity in slots 0..n-1,
Parameters
| w | the owned `^mut` world local (borrowed per iteration) | |
| n | slot count to scan (slots 0..n-1) | |
| binder | name bound to the proven-alive Entity for the body | |
| body | forms run per alive entity (result discarded; loop yields 0) |
Example
(for-each-alive! w 3 e
(println (rgworld-get-x! w e))) ;; proves; skips despawned slots
Since: RE1 2026-07-26
Internal definitions
rgw-allocrgw-genrgw-bumprgw-xgetrgw-xsetrgw-nextrgw-ctrl