Commit graph

346 commits

Author SHA1 Message Date
Yogthos
66c8c1157b fix: conj 0-arg, conj onto nil (builds list), conj map into map
- (conj) -> []
- (conj nil x ...) builds a list (prepends): (conj nil 1 2) -> (2 1)
- conj a map value into a map/phm merges its entries ((conj {:a 0} {:b 1}) ->
  {:a 0 :b 1}); a [k v] vector/pair still adds one entry.

conj.cljc 14/6/5 -> 21/3/1. clojure-test-suite pass 3681->3691, errors 105->98.
spec: seq/conj-edge-cases (8). jpm test green.
2026-06-05 10:30:07 -04:00
Yogthos
a4d9d5f70b fix: print Infinity/-Infinity/NaN like Clojure (str and pr-str)
Numbers printed via Janet's (string v) rendered infinities/NaN as inf/-inf/nan.
Add fmt-number so str/pr-str (and collection rendering) emit Infinity/-Infinity/
NaN. str.cljc 3->32 pass. Remaining str fails are the integer-valued-double
divergence ((str 0.0) is "0" not "0.0" since 0.0 == 0 in Janet).

spec: numbers/printing-of-inf-&-nan (5). jpm test green.
2026-06-05 10:23:57 -04:00
Yogthos
bcdace7543 fix: case composite constants, associative?/reversible?, update non-fn args, nth nil
- case: quote list literals (read as arrays) in constant position so a wrapped
  list ((a b c)) matches by value instead of being evaluated as a call; symbol
  constants already quoted. Vector/map/set constants already worked. case errors
  in the suite drop to 0 (60 pass).
- associative?: true only for vectors (pvec) and maps (phm/struct/sorted-map),
  not lists/tuples-from-seq-fns/lazy-seqs/sets.
- reversible?: true for vectors and sorted-map/sorted-set only.
- update: coerce f via as-fn so (update m k :kw)/(update m k a-set) work; extra
  args already handled.
- nth: (nth nil i)/(nth nil i default) returns nil/default instead of throwing.

clojure-test-suite pass 3649->3678, errors 122->105, clean files 44->46.
associative?/reversible? files now fully clean. spec: predicates + control/case.
jpm test green.
2026-06-05 10:19:43 -04:00
Yogthos
2ccfa675f7 fix: keyword/set/map as IFn in higher-order fns; nil-seq; take-nth/interpose/sort-by/min-key arities
Biggest fix: jolt keywords are Janet keywords and maps are Janet structs/phm, but
(:a struct) at the Janet level returns nil (not a Clojure accessor) and errors on
a phm — so core-map/filter/sort-by/group-by/etc. calling (f x) directly broke the
ubiquitous keyword/set/map-as-function idioms ((map :a coll), (sort-by :k coll),
(filter a-set coll), (group-by :type coll)). Added as-fn coercion (keyword/symbol
-> key lookup, map -> key lookup, set -> membership) applied at the entry of
map/filter/remove/keep/mapv/filterv/sort-by/group-by/partition-by/some/
not-any?/not-every?/take-while/drop-while/min-key/max-key.

Also:
- realize-for-iteration treats nil as an empty seq (Clojure semantics), fixing
  nth/nthrest/nthnext/take-last/reduce/doseq over nil.
- take-nth and interpose gained their 1-arg transducer arities.
- sort-by gained the 3-arg (keyfn comparator coll) form.
- min-key/max-key: single item returns it without calling f; ties keep the last.
- underive gained the 2-arg global-hierarchy form.

clojure-test-suite pass 3535->3649, errors 177->122, clean files 39->44.
spec: seq/IFn-values-as-functions (11). jpm test green.
2026-06-05 10:10:22 -04:00
Yogthos
acfcf2f94b feat: read N/M/ratio/radix/exponent number literals; clean suite measurement
Reader gaps caused the clojure-test-suite worker to crash whole deftests on
literals it could not parse (0N, 1.5M, 2r1010, 1/2), losing every assertion in
the file. read-number now handles:
- N (bigint) / M (bigdec) suffixes -> plain number (Jolt has no bignum/bigdec)
- ratios a/b -> double quotient
- radix integers NrDDD (2r1010, 16rFF, 36rZ) parsed by base
- exponents (1e3, 1.5e-2) and 0X hex

Also fixed suite measurement: when-var-exists now skips silently (its SKIP
print to stdout was corrupting the worker's count line, dropping whole files),
and the worker emits counts on an @@COUNTS sentinel line (robust against test
bodies that print, e.g. with-out-str). Runner parses the sentinel; deftest
crashes now report the underlying message.

Impact: clojure-test-suite 210->231 files run, pass 1955->3535, clean files
24->39. Baseline raised to 3450/38.

spec: numbers/literal-syntax (13 cases). jpm test green.
2026-06-05 09:54:14 -04:00
Yogthos
20ab88dd0c chore: beads sync for follow-up fixes 2026-06-05 09:36:08 -04:00
Yogthos
03652dce5d feat: ##Inf/##-Inf/##NaN literals, infinite?/NaN?, fix intval? for infinity
The reader now reads the symbolic float values ##Inf, ##-Inf and ##NaN. Added
infinite? and NaN? predicates. Fixed intval? to exclude infinity (floor(inf)=inf
but inf isn't integer-valued), so float?/double? are true for ##Inf and
int?/pos-int?/nat-int?/neg-int? are false for it.

This unblocked many number-test files whose  forms previously failed to
READ (##Inf/##NaN literals), so clojure-test-suite jumped from 2241 to 2539
assertions and pass 1719 -> 1955. Baseline raised to 1900. NaN_qmark now runs.

float?/double? on integer-valued doubles (1.0) remain false: Janet represents
an integer and an integer-valued double identically, so they're inherently
indistinguishable — documented in the README Numbers section.

spec: numbers/floats-&-symbolic-values (15 cases). jpm test green.
Closes jolt-fy8 (fixable parts; int-vs-float ambiguity is a documented divergence).
2026-06-05 09:35:44 -04:00
Yogthos
09532dac05 fix: transient invokable lookup, assoc! odd args, use-after-persistent! invalidation
Real transient correctness gaps surfaced by the clojure-test-suite:

- Transients are now invokable for read-only lookup like their persistent forms:
  ((transient v) i), ((transient m) k [default]), (:k (transient m)),
  ((transient s) x). jolt-invoke/coll-lookup gained a transient branch
  (transient-lookup) that indexes :arr / canon-keyed :tbl. Added phm/canon as a
  public canonicalizer so collection keys compare by value here too.
- assoc! accepts an ODD arg count (a missing final value is nil), unlike assoc —
  core-assoc! now uses nil-safe get for the value instead of erroring.
- Using a transient after persistent! (or a second persistent!, or pop! on an
  empty transient vector) now throws, via a :jolt/persistent invalidation flag
  checked by the mutating ops. Catches the classic transient footgun.

spec: transients-spec gains invokable-lookup (7), assoc!-odd-args (4),
invalidation (4). clojure-test-suite pass 1704->1719.

Remaining transient fails are accepted lenient divergences (jolt doesn't throw
on bad-shape conj!/assoc!/pop! of wrong-typed args; nil set elements). jpm test green.
2026-06-05 09:29:36 -04:00
Yogthos
e75771084e fix: merge nil/empty + conj semantics to match Clojure
core-merge returned {} for (merge) and errored on nil args. Rewrite to follow
Clojure: (when (some identity maps) (reduce conj (or (first maps) {}) (rest maps))).

- (merge) and (merge nil nil) -> nil
- nil args elsewhere are no-ops: (merge {} nil) -> {}, (merge nil {:a 1}) -> {:a 1}
- later args follow conj semantics: a map merges its entries, a [k v]
  vector/map-entry adds that entry ((merge {} [:foo 1]) -> {:foo 1},
  (merge {} (first {:a 1})) -> {:a 1})
- collection keys preserved (first arg's phm type kept; entries via core-assoc
  which promotes struct->phm for collection keys)

spec: 9 new merge cases in maps-spec. merge.cljc 13/18/11 -> 29/11/2.
clojure-test-suite pass 1688->1704. jpm test green.

Remaining merge.cljc fails are the lenient-where-Clojure-throws class (atomic
args, >2-element vectors). Fixes jolt-dxx.
2026-06-05 09:22:27 -04:00
Yogthos
2885650ef6 fix: transducers/reduce short-circuit over infinite seqs via reduced
transduce-reduce and core-reduce both called realize-for-iteration, fully
realizing the coll before the reduce loop — so an infinite lazy seq hung before
the reduced short-circuit could fire. (into [] (take 5) (range)) etc. never
terminated.

Add reduce-with-reduced, which steps a lazy seq one cell at a time
(realize-ls/ls cell protocol), checking reduced? after each element so a take/
take-while transducer (or any reducing fn returning reduced) terminates over an
infinite seq. Route transduce-reduce and both core-reduce arities through it;
2-arg reduce now seeds from the first element and reduces the rest lazily.

spec: transducers/short-circuit + reduce/honors-reduced (13 cases).
clojure-test-suite timeouts 7->6, pass 1683->1688. jpm test green.

Fixes jolt-kxb.
2026-06-05 09:18:35 -04:00
Yogthos
ae2899ba61 chore: beads issue tracking for conformance gaps 2026-06-05 09:05:41 -04:00
Yogthos
0ca678a159 test: port clojure-test-suite as baseline-guarded integration battery
Run the external cross-dialect clojure-test-suite (lread/clojure-test-suite,
240 per-fn .cljc files in clojure.test format) against Jolt:

- test/support/clojure_test.clj: minimal clojure.test + portability shims
  (deftest/is/testing/are + when-var-exists/thrown?/big-int?/lazy-seq?) — just
  enough surface to load the suite and tally pass/fail/error. Pre-loaded so the
  suite's (require [clojure.test ...]) finds it already populated.
- test/integration/suite-worker.janet: one-shot worker that loads the shim,
  the suite's number-range helper ns, and a single .cljc file, then prints
  'pass fail error'.
- test/integration/clojure-test-suite-test.janet: spawns a worker per file
  under an ev/with-deadline wall-clock budget (so infinite-seq tests that hang
  Jolt's eager evaluator are auto-contained, not a manual skip-list) and asserts
  pass/clean-file counts stay at/above a baseline. References ~/src/clojure-test-suite
  if present; skips cleanly when absent, like the jank battery.

Current: 210 files run, 7 timed out, 2233 assertions -> 1683 pass / 350 fail /
200 error, 23 clean files. Remaining fails are genuine divergences (float/ratio/
bigint, lenient transients where Clojure throws), tracked separately.

Fixes two real evaluator bugs the suite surfaced:
- :refer now preserves a referred macro's :macro flag (was interned as a plain
  value, degrading referred macros to functions).
- resolve-var now resolves ns aliases (like resolve-sym), so aliased macros
  (e.g. p/thrown? via :as p) dispatch as macros instead of being called as fns.
2026-06-05 09:04:38 -04:00
Yogthos
f38d402445 feat: real transients backed by Janet arrays/tables (interop)
Replace the correctness-only transient aliases with real mutable scratch
collections via host interop:
- transient vector -> a Janet array; conj!/assoc!/pop! mutate in place
- transient map -> a Janet table keyed by canonical key (collection keys still
  compare by value); assoc!/dissoc!/conj! mutate in place
- transient set -> a Janet table; conj!/disj! mutate in place
- persistent! freezes back to a pvec / phm / phs
- count/nth/get/contains? work on transients; transient? predicate added

Building a map/set this way avoids the persistent path's per-step bucket-array
copying (transient map build ~35% faster at 20k here); vectors are comparable
since pvec conj is already ~O(1). The mutating ops return the transient and the
source collection is untouched.

spec/transients-spec (34 cases). conformance 218/218, jpm test green.
2026-06-05 08:02:21 -04:00
Yogthos
a0943cb944 test: fold ported-clojure batteries into spec
Mine the remaining integration 'ported Clojure' batteries into the spec layer
and delete them (clojure-atom/control/for/logic/macros, core, logic). A broad
function-coverage diff confirmed they exercised no clojure.core fn the spec
lacked; their distinctive value was the truthiness/boolean contract, now
captured in a dedicated spec.

New/expanded spec coverage:
- spec/truthiness-spec: only nil/false are falsy (0, "", [], {}, #{} are truthy);
  not / and / or return-value & short-circuit semantics; if-not/when-not/boolean
- assert (exceptions-spec), get-validator (state-spec)

Layout now: spec 23 files / 732 cases; integration trimmed to 10 genuine
cross-cutting batteries (conformance, SCI bootstrap/runtime, jank, compile-mode,
api, namespace, bootstrap, features, systematic-coverage). conformance 218/218,
jpm test green.
2026-06-05 07:50:16 -04:00
Yogthos
a6491d025c docs: add EBNF grammar for the reader syntax (doc/grammar.ebnf)
Specify the surface syntax Jolt's reader accepts as an EBNF grammar — the
syntactic half of the contract (behavioural half is test/spec/). Grounded in
src/jolt/reader.janet and verified against the running reader: whitespace
(comma included), comments, #_ discard, scalars (nil/bool/number incl 0x hex &
floats/string/char incl \uNNNN \oNNN & named/keyword incl ::auto/symbol),
collections, reader macros (quote/syntax-quote/unquote/~@/deref/metadata), and
dispatch (#{}, #(), #', #"regex", #?/#?@, tagged #inst/#uuid). Jolt-vs-Clojure
deviations noted inline (no ratios/radix/BigInt literals; PEG regex limits).
Referenced from README.
2026-06-05 01:34:33 -04:00
Yogthos
e409edf8d9 chore: export beads (jolt-dd5 closed) 2026-06-05 01:24:07 -04:00
Yogthos
555cd7631e fix: catch binds unwrapped thrown value; var-set targets thread binding
Close jolt-dd5.
- catch now binds the originally-thrown value (unwrapping the :jolt/exception
  envelope), so (catch ... e (throw e)) rethrows the same exception instead of
  nesting another envelope, and (catch ... e e) on (throw 42) yields 42.
- var-set updates the innermost thread-binding frame for the var (replacing the
  stack slot) when the var is dynamically bound, matching Clojure; it falls back
  to the root otherwise.

Restored spec cases: exceptions rethrow + catch-binds-thrown-value, namespaces
var-set-in-binding. conformance 218/218, jpm test green.
2026-06-05 01:23:52 -04:00
Yogthos
a681daf7b9 test: fold cljs ports into spec; add exceptions spec + gap coverage
Mine the cljs port batteries into the spec layer and delete them (their behavior
is covered by spec; the unique functions they exercised are now specced).
Removed test/integration/ports/ entirely.

New/expanded spec coverage from the mining:
- spec/exceptions-spec: try/catch/finally, throw, ex-info/ex-message/ex-data/ex-cause
- doto, pr-str, keyword/symbol constructors, atom?, dynamic var binding

Two rare edges filed (jolt-...): rethrow of a caught ex-info re-wraps it; var-set
on a dynamic var inside binding no-ops. Core try/catch/ex-info and binding work.

Test layout is now spec (22 files, ~677 cases) / integration / unit / support.
conformance 218/218, jpm test green.
2026-06-05 01:12:39 -04:00
Yogthos
bcd0e42b33 test: fold phase ports into spec; promote compile-mode test
Mine the phase* port batteries into the spec layer and delete them (their
behavior is now covered by spec): phase5 (hierarchies), phase6 (tagged
literals/reader-conditionals), phase7 (lazy/sets), phase8+phase12 (protocols;
phase12 was a duplicate of phase8), phase10 (strings/set), phase13
(reify/walk). Unique cases mined into spec: reader #inst/#uuid/#?@ splice,
(Type. args) dot constructor, lazy-seq body-runs-once, keywordize-keys/
stringify-keys, custom :default key and explicit :hierarchy dispatch.

phase6-final tested the COMPILE-MODE path ({:compile? true}), distinct from the
interpreter-based spec — kept and renamed integration/compile-mode-test.

jpm test green, conformance 218/218.
2026-06-05 01:07:09 -04:00
Yogthos
3f5b42d784 chore: close jolt-do7 (collection keys) and jolt-e4p (regex PEG limits) 2026-06-05 01:03:05 -04:00
Yogthos
0db7eb6ac8 fix: value-semantics for collection keys/elements; set literals evaluate
Close jolt-do7. Maps/sets keyed by a collection (a map, vector, ...) now compare
by value instead of Janet identity:
- PHM/PHS hash and compare keys through an injected canonicalizer (collection
  keys -> value-hashable struct/tuple); keys are still stored as-is
- map literals and core-assoc promote to a phm when a key is a collection
- frequencies/group-by use a phm base so collection elements/keys dedup by value
- set equality is value-based (from earlier)

Real bugs found and fixed along the way:
- set literals #{(inc 1)} did not evaluate their elements (stored raw forms!)
- the REPL printer rendered phm maps as {} (they hit the deftype branch); now a
  phm branch prints entries

Added spec cases (maps/collection-keys, sets/literals & value elements).
conformance 218/218, jpm test green.
2026-06-05 01:02:00 -04:00
Yogthos
ad5539b0de test(spec): macros, reader, host-interop, namespaces — fix def-doc, resolve, %&
Final spec areas. Bugs caught and fixed:
- (def name docstring value) used the docstring as the value; now the 3-arg
  docstring form binds the value and records :doc meta
- resolve was a nil stub; now a special form resolving a symbol to its var
  (nil if unresolved). Added find-ns (non-creating lookup) and ns-name.
- in-ns didn't evaluate its arg, so (in-ns 'foo) failed; now evaluates it per
  Clojure (the integration test's unquoted form updated to the quoted idiom)
- #(... %& ...) built %& as a positional param instead of a & rest param;
  now emits (fn* [... & gen] ...) so %& captures the rest

Full public-API spec layer now in place. conformance 218/218, jpm test green.
2026-06-05 00:35:48 -04:00
Yogthos
e3d2aa8d14 test(spec): lazy sequences, transducers, metadata
Add spec suites covering lazy-seq/lazy-cat laziness, infinite + self-referential
seqs (ones/nats/fib), realized?; transducers (map/filter/take/cat/keep/mapcat as
xforms, comp, into/transduce/sequence/eduction/completing); and metadata
(with-meta/meta/vary-meta/^ reader). All passed against jolt as written — no
implementation changes needed. jpm test green.
2026-06-05 00:26:44 -04:00
Yogthos
a24e9bfba0 test(spec): state, multimethods, protocols — fix reify, get-method, hierarchies
Add spec suites for stateful refs (atoms/volatiles/delays/promises), multimethods
(dispatch + hierarchies), and protocols/types/records. Bugs caught and fixed:
- reify with multiple methods registered only the first (stepped i by 2 over
  one-element specs); now collects every method spec
- get-method/methods/remove-method evaluated their arg to the dispatch fn, but a
  multimethod's methods live on its var — now resolve the var (get-method and
  methods are special forms; remove-method fixed). get-method/methods added.
- no global hierarchy: 2-arg derive modified a throwaway, isa? was hardcoded
  false, parents missing, ancestors/descendants returned arrays (so contains?
  failed), and dispatch ignored derive. Now a global hierarchy backs the 1/2-arg
  derive/isa?/parents/ancestors/descendants (returning sets) and multimethod
  dispatch falls back to it.

Corrected a phase5 port assertion that encoded the old isa? bug.
conformance 218/218, jpm test green.
2026-06-05 00:24:18 -04:00
Yogthos
50d63d896f test(spec): control-flow, functions, destructuring — fix loop destructuring
Add spec suites for conditionals/logic/let/loop/iteration/threading, functions
(definition, application, combinators), and destructuring across let/fn/loop/
doseq/for. Bug caught and fixed: loop* assumed simple-symbol bindings, so
(loop [[a b] [1 2]] ...) errored; it now destructures each binding via
destructure-bind, supporting patterns in loop bindings (and recur). jpm test green.
2026-06-05 00:16:15 -04:00
Yogthos
68d6b1d6c1 test(spec): numbers, strings, predicates — fix variadic <, seq?, index-of
Add spec suites for numbers/arithmetic, strings (str + clojure.string), and
type/value predicates. Bugs they caught and fixed:
- <, >, <=, >= were binary-only; now variadic ((< 1 2 3) chains)
- seq? was true for vectors; vectors are not ISeq in Clojure, so (seq? [1])
  is now false (true only for lists/lazy-seqs)
- clojure.string/index-of and last-index-of were 1-based (stray inc); now
  0-based per Clojure

Corrected a systematic-coverage assertion that encoded the old seq? bug.
jpm test green, conformance 218/218.
2026-06-05 00:13:19 -04:00
Yogthos
b353d625f1 test(spec): collections contract (sequences, vectors, lists, maps, sets)
Add behavioral spec suites for the collection API (~180 cases). Writing them
surfaced and fixed real bugs:
- (count nil) errored; now 0 (Clojure semantics)
- (repeat x) and (repeatedly f) — the infinite 1-arg arities — were unsupported;
  now return lazy infinite seqs
- set equality used deep= (representation-sensitive), so a set of map literals
  could differ from an equal set built differently; now value-based (each
  element value-equal to some element of the other)

Known limitation filed: phm-typed maps (from hash-map) used as set elements /
map keys hash by identity (map *literals* are structs and work).

jpm test green.
2026-06-05 00:08:37 -04:00
Yogthos
16428179fa test: restructure into unit / integration / spec layers + shared harness
Reorganize the flat 49-file test/ into three layers (jpm test recurses, so all
are still discovered):
- test/unit/        white-box component tests (reader, evaluator, types,
                    persistent-map, lazy-seq, macro, interop, compiler)
- test/integration/ cross-cutting + regression batteries (conformance, jank,
                    sci-bootstrap/runtime, features, systematic-coverage, api,
                    core, namespaces, ported clojure suites) and
   .../ports/       ported clojure/cljs test batches pending consolidation
- test/spec/        the behavioral contract (built out in following commits)
- test/support/harness.janet  shared defspec table runner (cases compared via
                    Jolt's own =, with a :throws sentinel) + expect= helpers

Files moved with git mv (history preserved) and import paths fixed for depth.
jpm test green. README Test section updated.

Next: build out test/spec/ to cover the public API area-by-area, mining the
integration batteries and filling gaps.
2026-06-05 00:00:16 -04:00
Yogthos
1898308926 docs: refresh Differences — bigint/+'/transients/byte-arrays now provided
Update stale claims: bigint/biginteger (int/s64), +'/*'/inc' aliases, transients
(correctness-only), and the byte-array-via-buffer / array family are now
implemented. Note clojure.repl/template and JVM reflection/proxy remain out.
2026-06-04 23:48:38 -04:00
Yogthos
bf754693b5 feat: SCI bootstrap loads completely (422/422) — fix with-meta + select-keys
The last two keystone forms in namespaces.cljc now load, so the entire SCI
source in the harness's load order evaluates with ZERO failures (was 420/2).

Two real bugs fixed to get there:
- with-meta crashed on non-collections: (with-meta a-fn {...}) did (keys fn) ->
  'expected iterable, got function'. SCI marks core fns private this way. Now
  returns functions/scalars unchanged (Jolt can't attach meta to a raw fn).
- select-keys ignored a vector key-list: (each k ks) iterated the pvec's table
  instead of its elements, so (select-keys m [:a]) returned {}. Now realizes ks.

Plus: add clojure.set/join (the only missing clojure.set fn), assert 0 failures
in test-load-sci so it's a real regression guard, drop debug instrumentation.

Jolt now fully loads SCI's reader-independent implementation: every pure-Clojure
module, the entire clojure.core aggregation map, and the clojure.* namespace
wiring. conformance 218/218, features 78/78, jank 120.
2026-06-04 23:35:19 -04:00
Yogthos
4eead1ac0f fix: deftype now registers inline protocol/interface methods
Raw (deftype T [fields] Proto (method [this] body) ...) silently ignored its
protocol body — only the constructor was created, so protocol dispatch on a
deftype instance always failed (No method ... for T). defrecord worked only
because its macro expanded the body into extend-type forms.

deftype now does the same: emit an extend-type per protocol, wrapping each
method body in a let that binds the type's fields from the instance. This is a
real correctness fix (any deftype-with-protocols was broken) and unblocks SCI's
sci.lang.Var (a deftype implementing vars/IVar) — the clojure.core aggregation
map now gets past protocol dispatch.

conformance 218/218, features 78/78, jank 120.
2026-06-04 23:26:25 -04:00
Yogthos
e52c445113 feat: stub SCI host modules, fix require :as+:refer, +promoting ops/eduction
Push SCI loading much further: the giant clojure.core aggregation map in
namespaces.cljc now resolves ALL its symbols (it previously failed on dozens).

- host_stubs.clj: forward-decl no-op fns for SCI's host-layer modules
  (parser/read/load/macroexpand/resolve/proxy/reify) — Jolt supplies its own
  reader/loader, so these only need to resolve when the binding map is built.
  Stubs are non-nil fns so :refer re-interns them (a nil-valued var is dropped).
- Load Jolt's clojure.string/set/walk/edn before namespaces.cljc.
- Add real clojure.core: ==, print-str, eduction/->Eduction,
  seq-to-map-for-destructuring, split-lines, postwalk-demo/prewalk-demo,
  +'/-'/*'/inc'/dec' (Jolt doesn't overflow, so == non-quoted), proxy-super
  and friends (resolve-only, JVM-specific).

Fix a real require bug: eval-require stopped at the first option, so
[ns :as x :refer [...]] silently dropped the :refer. Now processes all options.

SCI load: clojure.core map now builds; only two forms remain (a Var-protocol
method on sci.lang.Var, and the clojure.repl namespace). conformance 218/218,
features 78/78, jank 120.
2026-06-04 20:53:45 -04:00
Yogthos
dd51322ff1 feat: load SCI's pure-Clojure modules + adapt remaining core vars; fix defmethod
Load SCI's macro/expander modules from real source (destructure, doseq_macro,
for_macro, fns, multimethods) in the test harness — all load with 0 failures,
which resolved the sci-internal refs (doseq-macro/expand-doseq, fns/fn**, ...)
that previously blocked namespaces.cljc.

Add the remaining clojure.core vars, adapting JVM-isms to the Janet runtime:
enumeration-seq/iterator-seq -> plain seq, xml-seq -> tree walk, subseq/rsubseq
over sorted colls, char-escape-string/char-name-string, line-seq; resolve-only
for genuinely-JVM bean/proxy/print-method/print-dup/undefined?.

Fix a real defmethod bug: it errored when the multimethod symbol resolved to a
plain fn with no method table (e.g. a copy-core-var'd print-method) — now it
initializes the table, so (defmethod print-method T ...) works.

SCI load: 420/422 forms (was 390/392); only the two keystone aggregation maps
in namespaces.cljc remain. conformance 218/218, features 78/78, jank 120.
2026-06-04 20:39:31 -04:00
Yogthos
74ac197e9d feat: real Java-array family via Janet buffers/arrays + ~30 more core fns
Replace the would-be error-stubs with real implementations backed by Janet's
C primitives, per the principle that these aren't things Jolt can't do — Janet
does them natively:

- Byte arrays -> Janet buffers (contiguous, C-backed, O(1) indexed get/put):
  byte-array/bytes/aset-byte/aget/alength/aclone. Genuinely fast for byte work.
- Object & numeric arrays -> Janet arrays: object-array/int-array/long-array/
  double-array/float-array/short-array/char-array/boolean-array, make-array,
  into-array, to-array(-2d), multi-dim aget/aset, typed aset-*.
- 64-bit ints -> Janet int/s64 (bigint/biginteger); bigdec -> double.
- Casts: byte/short/unchecked-byte/short/char/float/double, bytes/ints/longs/...
- Chunked seqs: simple eager equivalents (Jolt does not chunk).
- Plus boolean, cat (transducer), disj!, random-sample, reader-conditional?,
  sorted-map-by/sorted-set-by, array-seq, class, munge, clojure-version,
  supers, test, rationalize, seque.

seq/reduce/map/count now work over byte-array buffers (realize-for-iteration +
core-seq handle buffers).

This took the SCI clojure.core aggregation map from 106 -> 21 missing core vars
(the rest are CLJS / Java-reflection / proxy — not applicable to a Janet host).
conformance 218/218, features 78/78, jank 120.
2026-06-04 20:23:48 -04:00
Yogthos
c275112a5f feat: transients, unchecked arithmetic, hash helpers + fix REPL set printer
More clojure.core coverage (real implementations, not stubs):
- transient/persistent!/conj!/assoc!/dissoc!/pop! as correctness-preserving
  aliases (Jolt collections are persistent, so no in-place speedup but correct)
- unchecked-* arithmetic (Jolt numbers don't overflow -> plain ops)
- hash-combine/hash-ordered-coll/hash-unordered-coll (24-bit masked to stay
  in integer range), ex-cause (ex-info now records a cause), prefers, random-uuid

Fix a pre-existing REPL bug: the set printer in main.janet iterated the backing
phm's table keys (:buckets/:cnt) instead of the elements, so every set printed
as #{:buckets :cnt} at the REPL (pr-str was already correct). Now uses phs-seq.

conformance 218/218, features 78/78, jank 120.
2026-06-04 19:43:19 -04:00
Yogthos
39edb88074 feat: ~40 more core fns + fix map iteration to yield entries
While digging into test-load-sci, add genuinely-missing clojure.core fns:
doall/dorun/run!/tree-seq, key/val/map-entry?, rand-nth/replicate/
bounded-count/counted?/reversible?/seqable?, nat-int?/pos-int?/neg-int?/
double?/float?/ratio?/decimal?/rational?/numerator/denominator, list*,
special-symbol?/record?, promise/deliver, comparator/completing/halt-when/
ensure-reduced/unreduced, keyword-identical?/object?/tagged-literal/re-groups.

Fix a real pre-existing bug: iterating a map (first/seq/map/filter/reduce/vec/
realize-for-iteration) returned keys or values instead of [k v] entries.
Map literals are Janet structs (not phm), which several paths mishandled.
Now first/seq/realize-for-iteration yield entries for both structs and phms,
matching Clojure — e.g. (vec {:a 1}) => [[:a 1]], (map key m), (reduce f init m).

Tests: conformance 218/218 (+12), features 78/78, jank 120. Advances the SCI
bootstrap further (its clojure.core aggregation map resolves more symbols).
2026-06-04 19:38:25 -04:00
Yogthos
a0c9696900 feat: persistent singly-linked lists with O(1) conj/cons prepend
Round 3 of the persistent-collections work. Lists were immutable Janet arrays,
so conj/cons-prepend was an O(n) copy (O(n^2) to build a list) — a large perf
gap vs Clojure's PersistentList.

Add src/jolt/plist.janet: an immutable cons-cell list (first/rest/count), same
algorithm as Clojure/CLJS/jank PersistentList. conj/cons onto a list now creates
an O(1) node that shares the existing list as its tail (no copy), with a cached
O(1) count. Repeated conj is O(n) total instead of O(n^2).

Hooked plist through first/rest/next/seq/count/peek/pop/nth/empty/empty?, the
predicates (list?/seq?/coll?/sequential?), realize-for-iteration, =, coll->cells
(concat/lazy), both printers, destructuring, and instance? tags. (list ...) and
quoted lists stay arrays; only conj/cons introduce plist nodes, so the surface
and risk stay small.

Verified: reduce-conj of 200k elements runs in ~0.4s (was effectively O(n^2)).
conformance 206/206, features 78/78 (+7 list regressions), jank 120 (+1).
2026-06-04 19:20:27 -04:00
Yogthos
e43f39bc36 feat: add missing core fns (bit-clear, get-method, second, predicates, ...)
Resolve symbols that were unbound or leaking to broken Janet builtins:
- bit-clear/bit-set/bit-flip/bit-test/bit-and-not
- get-method/methods (multimethod introspection)
- second/ffirst/nfirst/fnext/nnext, last (was leaking to Janet, broke on pvec),
  drop-last/take-last
- ident?/simple-symbol?/qualified-keyword?/simple-keyword?/simple-ident?/
  qualified-ident?/inst?/inst-ms/uri?/uuid?/bytes?/tagged-literal?
- clojure.string/re-quote-replacement

Advances the SCI bootstrap; conformance 206/206, features 71/71.
2026-06-04 19:10:45 -04:00
Yogthos
1eb2843365 feat: structural-sharing persistent vectors (immutable build) + mutable toggle
Round 2 of the persistent-collections work.

Add a real 32-way branching-trie persistent vector (src/jolt/pv.janet) with a
tail buffer: O(log32 n) conj/assoc/nth/pop, with unchanged subtrees shared by
identity. Vector literals and vec/vector/conj/assoc/subvec/etc. now produce and
maintain these in the default (immutable) build, replacing the old tuple-based
vectors. Every core seq op, the destructurer, IFn application, the printers, =,
and the evaluator's literal/splice paths were taught to handle the pvec type.

Define several Clojure seq fns that were silently leaking to Janet builtins
(some, keep, interleave, flatten, mapcat, interpose) and broke once vectors
became tables; normalize collections through realize-for-iteration everywhere.

Build-time JOLT_MUTABLE flag now selects fast Janet-native mutable collections:
in that mode vectors are arrays (conj appends in place, vector? true, print []),
sharing one representation with lists. Default build is immutable.

Tests: conformance 206/206, features 71/71, jank 119 (baseline). Test helpers
normalized so Janet-level = compares against tuple literals regardless of repr.
The 2 test-load-sci failures (bit-clear/get-method) pre-date this work.
2026-06-04 18:56:55 -04:00
Yogthos
1ca93d61c6 feat: build-time mutable/immutable collection toggle + fix list mutation
Add src/jolt/config.janet exposing a build-time `mutable?` constant read from
JOLT_MUTABLE at compile time (jpm build). Default is immutable.

Fix correctness bug: conj on a list (Janet array) mutated the original in
place. In immutable mode conj now copies first; in mutable mode it mutates.

Round 1 of persistent-collections work.
2026-06-04 18:15:48 -04:00
Yogthos
96e23c5235 test: add jank-conformance harness — runs jank's Clojure pass-tests from local ~/src/jank (MPL, not vendored; skips if absent) and asserts >=119 pass as a regression baseline 2026-06-04 18:05:03 -04:00
Yogthos
305868fd88 feat: named fn* — (fn* name [args] ...) binds name to self for recursion (unblocks named-recur; jank conformance 110->119) 2026-06-04 18:02:55 -04:00
Yogthos
00a5dcacde cleanup 2026-06-04 18:00:33 -04:00
Yogthos
3e12ef31e3 fix: assert was a no-op (fell through to Janet builtin); add proper Clojure assert macro that throws on falsy; err-message unwraps ex-info 2026-06-04 17:58:30 -04:00
Yogthos
aeaf1b624c test: add features-test.janet (71 assertions mirroring all clojure-features.clj sections + expansions + demo smoke test); fix 3 bugs it caught — for :while ignored, map->Record params (array vs tuple), extend-protocol to host types (Long/String/Number) now dispatches 2026-06-04 17:45:31 -04:00
Yogthos
1b37e56df4 feat: map literals evaluate their values (fixes critical latent bug); expand SCI bootstrap to 14 files (ctx_store/deftype/records/core_protocols/hierarchies + sci.impl.io stub), 390/392 forms; fix multi-arity defmethod (builds fn*) and variadic macrofy; SCI test loaders tolerant of the 2 redundant clojure.core registration maps 2026-06-04 17:28:44 -04:00
Yogthos
7d490843e5 feat: clojure-features demo runs end-to-end (Janet interop in §14, real exception demo in §11); fix syntax-quote (auto-gensym foo#, leave core/special unqualified) so macros work; (. obj sym) is a zero-arg method call; add long/double/float/num coercions; print Janet stack trace on errors (REPL/file/-e) 2026-06-04 17:08:18 -04:00
Yogthos
f20df44d6a docs: lean README — drop stale internals/project-structure, document divergences from Clojure (host/numbers/collections/STM/regex), fix interop examples to working calls 2026-06-04 16:48:45 -04:00
Yogthos
e87f6db10e feat: CLI file execution — 'jolt file.clj [args]' runs a script (binds *command-line-args*/*file*), '-e EXPR' evaluates, '-h' help; fix print/println/pr/prn to space-separate, render collections, and not double-newline 2026-06-04 16:40:04 -04:00
Yogthos
37c8971d41 feat: full regex engine (Path A) — parser->AST->PEG grammar with continuation-passing backtracking + position-based group captures; capturing groups [whole g1...], greedy/lazy backtracking through groups, lookahead, (?i) flag, anchors/\b, $N replace; re-find/matches/seq + string split/replace 2026-06-04 16:24:02 -04:00