Chez Phase 2 (inc E): meta / with-meta

meta/with-meta resolved to jolt-nil. Chez values don't carry metadata, so
collections use an identity-keyed side-table: with-meta returns a fresh copy of
the value (new identity) and records its meta there, leaving the original
unchanged (immutable-with-meta) and dropping meta on a later copying op. Symbols
carry meta in their existing field; meta on a non-metadatable value is nil.
vary-meta works over these. with-meta on a fn stays fn? (jolt is lenient).

emit.janet carries a quoted symbol's reader metadata (^:foo bar) onto the
emitted jolt-symbol so (meta 'x) sees it; symbol = still ignores meta.

Prelude parity 1701 -> 1723, 0 new divergences. jolt-rkbc.
This commit is contained in:
Yogthos 2026-06-18 12:16:48 -04:00
parent f0419b560d
commit b8e4e78372
4 changed files with 54 additions and 4 deletions

View file

@ -201,9 +201,14 @@
(or (nil? form) (boolean? form) (number? form) (string? form) (keyword? form))
(emit-const form)
(and (struct? form) (= :symbol (get form :jolt/type)))
(let [ns (get form :ns)]
(string "(jolt-symbol " (if ns (chez-str-lit ns) "#f") " "
(chez-str-lit (get form :name)) ")"))
(let [ns (get form :ns)
m (get form :meta)]
(if (and m (not (nil? m)) (> (length m) 0))
# carry reader metadata (^:foo bar) onto the quoted symbol so (meta 'x) sees it
(string "(jolt-symbol/meta " (if ns (chez-str-lit ns) "#f") " "
(chez-str-lit (get form :name)) " " (emit-quoted m) ")")
(string "(jolt-symbol " (if ns (chez-str-lit ns) "#f") " "
(chez-str-lit (get form :name)) ")")))
(and (struct? form) (= :jolt/char (get form :jolt/type))) (emit-const form)
(and (struct? form) (= :jolt/set (get form :jolt/type)))
(string "(jolt-hash-set " (string/join (map emit-quoted (get form :value)) " ") ")")