The script is in tools/ rather than thrown away, because two lanes are
writing Flan in the old spelling right now and their files need the same
pass at merge.
It works on forms, not on text: a keyword becomes a dot only where it sits
in a field-label position inside a brace, so an enum member in value
position, a map key inside an EDN string and a type-position {K V} are all
left alone. :keys keeps its colon -- it names no field.
22 lines
770 B
Plaintext
22 lines
770 B
Plaintext
;;;; Value semantics, spec-memory.md. Not covered by calc-me, and the property
|
|
;;;; most likely to be silently wrong in a backend: a struct or a fixed array
|
|
;;;; copies on assignment, a slice copies only its view.
|
|
(defstruct P [x i32])
|
|
(defvar arr [3 i32])
|
|
|
|
(defn main [] i32
|
|
(let [a (P {.x 1})]
|
|
(let [b a] ; a copy, not an alias
|
|
(set (.x a) 99)
|
|
(print (.x b)) (println ""))) ; 1
|
|
|
|
(set (at arr 0) 5)
|
|
(let [c arr] ; fixed arrays are values too
|
|
(set (at arr 0) 77)
|
|
(print (at c 0)) (println "")) ; 5
|
|
|
|
(let [s (bytes "hello")]
|
|
(let [v (slice s 1 3)] ; a view into the same bytes
|
|
(print v) (println ""))) ; el
|
|
0)
|