(defconst rows 3) (defconst cols 4) ;; A fixed array is a value: inline storage, copies on assignment. (defconst palette [4 u32] [0xE6B800FF 0x3B6E8CFF 0xA83232FF 0xCC6B1FFF]) ;; No initialiser means all-bytes-zero, so this is BSS and costs nothing. (defvar grid [rows [cols i32]]) (defn main [] () (set (at grid 1 2) 7) (print (at grid 1 2)) (println "") ; 7 (print (len palette)) (println "") ; 4 ;; A slice is ptr+len and non-owning: it views the array, it does not copy it. (let [row (slice (at grid 1) 0 cols)] (set (at row 0) 5) (print (at grid 1 0)) (println "") ; 5 — the same storage (print (sum-i32 row)) (println "")) ; 12 ;; (zeroed) is a memset, not an allocation. (set grid (zeroed)) (print (at grid 1 2)) (println "")) ; 0