flan/web/examples/places.flan
Joseph Ferano 86ef557433 Run the break loop rather than quote it, since the restart order is a claim
NEXT.md prints the banner with the restarts in source order; the walk is
innermost-first, so it is the other way round. A --dev build under timeout is
enough to settle that, and settles the two place and global snippets with it.
2026-09-12 03:43:24 +07:00

21 lines
738 B
Plaintext

(defstruct Enemy [hp i32 name string])
(defvar spawned i32)
(defconst room-size 4)
(defvar room [room-size i32])
;; `set` takes a fixed list of forms, not an extensible setf.
(defn main []
(let [e (Enemy {:hp 10 :name "slime"})
p (addr e)]
(set spawned (+ spawned 1)) ; a local or a defvar
(set (.hp e) 7) ; a struct field
(set (.hp p) 8) ; through a (Ptr Enemy) — derefs one level
(set (at room 2) 5) ; a fixed array or slice element
(set (deref p) (Enemy {:hp 3 :name "wisp"})) ; a whole-object store
(print-i64 (i64 (.hp e))) (newline)
(print-line (.name e))
(print-i64 (i64 (at room 2))) (newline)
(print-i64 (i64 spawned)) (newline)))