print and println had no line anywhere on index.html — a builtin the reader meets in the first example and is never told about. There is a section for them now, between arrays and the prelude: what the walk covers, that an enum comes back as its name and a Ptr does not get followed, that a string is raw at the top and quoted inside a structure, and that the depth and span caps are what keep a grid from printing a screenful. printing.flan is beside the other examples so check.sh has been green on every line of it. The prelude's table loses its output row, because the prelude has no output functions left, and the fifty-odd example blocks follow the files they quote. Two pinned things moved. sand-headless prints 15595743031174623232 where it printed -2851001042534928384: same bits, read unsigned, because the cast that made it signed is gone. bounds.flan's trap moved from column 28 to 19, which is where (at xs i) now starts on that line. And the indirection-cell illustration is defer.flan rather than hello.flan. hello.flan cannot show a cell any more: its one call was to a prelude function, and println is compiler-provided, so the smallest program makes no Flan-to-Flan call at all. defer.flan's main calls work, and is already on the page a few sections up.
24 lines
814 B
Plaintext
24 lines
814 B
Plaintext
(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
|