eliscript 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +674 -0
- package/README.md +135 -0
- package/bin/eliscript +16 -0
- package/bin/eliscript-bootstrap +15 -0
- package/bin/eliscript-build +15 -0
- package/bin/eliscript-check +15 -0
- package/bin/eliscript-eval +15 -0
- package/bin/eliscript-format +15 -0
- package/bin/eliscript-org +10 -0
- package/bin/eliscript-portable +17 -0
- package/bin/eliscript-seed +10 -0
- package/bin/eliscript-seed-build +10 -0
- package/bin/eliscript-watch +15 -0
- package/bootstrap/README.md +100 -0
- package/bootstrap/compiler/analyzer.eli +1426 -0
- package/bootstrap/compiler/compiler.eli +472 -0
- package/bootstrap/compiler/emitter.eli +1745 -0
- package/bootstrap/compiler/expander.eli +2522 -0
- package/bootstrap/compiler/formatter.eli +359 -0
- package/bootstrap/compiler/ir.eli +297 -0
- package/bootstrap/compiler/lower.eli +661 -0
- package/bootstrap/compiler/project.eli +1120 -0
- package/bootstrap/compiler/reader.eli +321 -0
- package/bootstrap/compiler/source-map.eli +165 -0
- package/bootstrap/compiler/symbol.eli +92 -0
- package/bootstrap/compiler/syntax.eli +54 -0
- package/bootstrap/compiler/transient-analysis.eli +825 -0
- package/bootstrap/host/build.mjs +28 -0
- package/bootstrap/host/bun.mjs +282 -0
- package/bootstrap/host/check-cli.mjs +163 -0
- package/bootstrap/host/eliscript-cli.mjs +36 -0
- package/bootstrap/host/evaluation-cli.mjs +401 -0
- package/bootstrap/host/evaluation.mjs +560 -0
- package/bootstrap/host/format-cli.mjs +139 -0
- package/bootstrap/host/project-cli.mjs +295 -0
- package/bootstrap/host/project.mjs +1080 -0
- package/bootstrap/host/watch-cli.mjs +129 -0
- package/bootstrap/host/watch.mjs +267 -0
- package/browser/host.mjs +357 -0
- package/browser/worker.mjs +60 -0
- package/compiler/README.md +118 -0
- package/compiler/eliscript-analyzer.el +716 -0
- package/compiler/eliscript-cli.el +108 -0
- package/compiler/eliscript-diagnostic.el +158 -0
- package/compiler/eliscript-emitter.el +1351 -0
- package/compiler/eliscript-evaluation.el +259 -0
- package/compiler/eliscript-expander.el +1630 -0
- package/compiler/eliscript-form.el +79 -0
- package/compiler/eliscript-ir-emitter.el +1460 -0
- package/compiler/eliscript-ir.el +356 -0
- package/compiler/eliscript-lower.el +463 -0
- package/compiler/eliscript-macro-eval.el +811 -0
- package/compiler/eliscript-parameters.el +324 -0
- package/compiler/eliscript-portable.el +492 -0
- package/compiler/eliscript-project-cli.el +156 -0
- package/compiler/eliscript-project.el +1676 -0
- package/compiler/eliscript-reader.el +421 -0
- package/compiler/eliscript-source-map.el +192 -0
- package/compiler/eliscript-symbol.el +101 -0
- package/compiler/eliscript-transient-analysis.el +817 -0
- package/compiler/eliscript.el +239 -0
- package/dist/bootstrap/analyzer.mjs +968 -0
- package/dist/bootstrap/analyzer.mjs.map +1 -0
- package/dist/bootstrap/compiler.mjs +228 -0
- package/dist/bootstrap/compiler.mjs.map +1 -0
- package/dist/bootstrap/emitter.mjs +1173 -0
- package/dist/bootstrap/emitter.mjs.map +1 -0
- package/dist/bootstrap/expander.mjs +1469 -0
- package/dist/bootstrap/expander.mjs.map +1 -0
- package/dist/bootstrap/formatter.mjs +304 -0
- package/dist/bootstrap/formatter.mjs.map +1 -0
- package/dist/bootstrap/ir.mjs +193 -0
- package/dist/bootstrap/ir.mjs.map +1 -0
- package/dist/bootstrap/lower.mjs +344 -0
- package/dist/bootstrap/lower.mjs.map +1 -0
- package/dist/bootstrap/project.mjs +585 -0
- package/dist/bootstrap/project.mjs.map +1 -0
- package/dist/bootstrap/reader.mjs +259 -0
- package/dist/bootstrap/reader.mjs.map +1 -0
- package/dist/bootstrap/source-map.mjs +154 -0
- package/dist/bootstrap/source-map.mjs.map +1 -0
- package/dist/bootstrap/symbol.mjs +74 -0
- package/dist/bootstrap/symbol.mjs.map +1 -0
- package/dist/bootstrap/syntax.mjs +38 -0
- package/dist/bootstrap/syntax.mjs.map +1 -0
- package/dist/bootstrap/transient-analysis.mjs +660 -0
- package/dist/bootstrap/transient-analysis.mjs.map +1 -0
- package/dist/browser/compiler.js +6491 -0
- package/editor/README.md +83 -0
- package/editor/eliscript-mode.el +878 -0
- package/editor/eliscript-repl.el +501 -0
- package/package.json +163 -0
- package/platform/README.md +48 -0
- package/platform/browser.mjs +204 -0
- package/platform/worker.mjs +166 -0
- package/runtime/README.md +296 -0
- package/runtime/core/collection-internals.mjs +512 -0
- package/runtime/core/collection.mjs +645 -0
- package/runtime/core/data-text.mjs +532 -0
- package/runtime/core/data.mjs +268 -0
- package/runtime/core/identifier.mjs +314 -0
- package/runtime/core/lazy-sequence.mjs +244 -0
- package/runtime/core/list-internals.mjs +18 -0
- package/runtime/core/list.mjs +273 -0
- package/runtime/core/map-internals.mjs +793 -0
- package/runtime/core/map.mjs +394 -0
- package/runtime/core/metadata-internals.mjs +14 -0
- package/runtime/core/metadata.mjs +44 -0
- package/runtime/core/object-impl.mjs +65 -0
- package/runtime/core/object-impl.mjs.map +1 -0
- package/runtime/core/object.mjs +13 -0
- package/runtime/core/order.mjs +234 -0
- package/runtime/core/persistent-kind.mjs +43 -0
- package/runtime/core/protocol-error.mjs +36 -0
- package/runtime/core/protocol-impl.mjs +326 -0
- package/runtime/core/protocol-impl.mjs.map +1 -0
- package/runtime/core/protocol.mjs +14 -0
- package/runtime/core/queue-internals.mjs +27 -0
- package/runtime/core/queue.mjs +238 -0
- package/runtime/core/record.mjs +346 -0
- package/runtime/core/regex.mjs +184 -0
- package/runtime/core/sequence.mjs +632 -0
- package/runtime/core/set-algebra.mjs +287 -0
- package/runtime/core/set-internals.mjs +33 -0
- package/runtime/core/set.mjs +378 -0
- package/runtime/core/sorted-internals.mjs +215 -0
- package/runtime/core/sorted.mjs +598 -0
- package/runtime/core/text-impl.mjs +95 -0
- package/runtime/core/text-impl.mjs.map +1 -0
- package/runtime/core/text.mjs +15 -0
- package/runtime/core/transducer.mjs +668 -0
- package/runtime/core/transient-internals.mjs +38 -0
- package/runtime/core/transient.mjs +53 -0
- package/runtime/core/truth.mjs +3 -0
- package/runtime/core/type.mjs +262 -0
- package/runtime/core/value-internals.mjs +188 -0
- package/runtime/core/value.mjs +93 -0
- package/runtime/core/vector-internals.mjs +102 -0
- package/runtime/core/vector.mjs +951 -0
- package/runtime/literals.mjs +34 -0
- package/runtime/source-mapping.mjs +220 -0
- package/runtime/testing/list.mjs +52 -0
- package/runtime/testing/map.mjs +145 -0
- package/runtime/testing/queue.mjs +49 -0
- package/runtime/testing/set.mjs +61 -0
- package/runtime/testing/sorted.mjs +105 -0
- package/runtime/testing/value.mjs +17 -0
- package/runtime/testing/vector.mjs +102 -0
- package/runtime/worker-value-codec.mjs +565 -0
- package/runtime/worker-value-stream.mjs +786 -0
- package/runtime/worker.mjs +975 -0
- package/stdlib/README.md +774 -0
- package/stdlib/bit.eli +36 -0
- package/stdlib/core/collection.eli +134 -0
- package/stdlib/core/data-text.eli +16 -0
- package/stdlib/core/data.eli +306 -0
- package/stdlib/core/identifier.eli +32 -0
- package/stdlib/core/lazy-sequence.eli +63 -0
- package/stdlib/core/metadata.eli +20 -0
- package/stdlib/core/object.eli +89 -0
- package/stdlib/core/order.eli +133 -0
- package/stdlib/core/protocol.eli +387 -0
- package/stdlib/core/record.eli +16 -0
- package/stdlib/core/regex.eli +17 -0
- package/stdlib/core/seq.eli +701 -0
- package/stdlib/core/set.eli +312 -0
- package/stdlib/core/sorted.eli +53 -0
- package/stdlib/core/text.eli +103 -0
- package/stdlib/core/transducer.eli +59 -0
- package/stdlib/core/transient.eli +24 -0
- package/stdlib/core/type.eli +19 -0
- package/stdlib/core/walk.eli +195 -0
- package/stdlib/core/zipper.eli +508 -0
- package/stdlib/data-text.eli +1092 -0
- package/stdlib/data.eli +42 -0
- package/stdlib/deferred.eli +70 -0
- package/stdlib/function.eli +120 -0
- package/stdlib/hierarchy.eli +245 -0
- package/stdlib/identifier.eli +147 -0
- package/stdlib/interop/js.eli +616 -0
- package/stdlib/json.eli +870 -0
- package/stdlib/metadata.eli +56 -0
- package/stdlib/multimethod.eli +464 -0
- package/stdlib/numeric.eli +193 -0
- package/stdlib/object.eli +96 -0
- package/stdlib/persistent-list.eli +145 -0
- package/stdlib/persistent-map.eli +724 -0
- package/stdlib/persistent-queue.eli +32 -0
- package/stdlib/persistent-set.eli +236 -0
- package/stdlib/persistent-vector.eli +342 -0
- package/stdlib/result.eli +141 -0
- package/stdlib/sequence.eli +106 -0
- package/stdlib/state/atom.eli +265 -0
- package/stdlib/text.eli +88 -0
- package/stdlib/value.eli +325 -0
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
# Runtime
|
|
2
|
+
|
|
3
|
+
[Project README](../README.md) | [Standard library](../stdlib/README.md) |
|
|
4
|
+
[Specifications](../specs/README.md)
|
|
5
|
+
|
|
6
|
+
## Boundary
|
|
7
|
+
|
|
8
|
+
This directory contains the minimal JavaScript runtime semantics that cannot be
|
|
9
|
+
represented by ordinary host values alone. Ordinary JavaScript values and APIs
|
|
10
|
+
should still be emitted directly; helpers need a concrete semantic reason to
|
|
11
|
+
exist.
|
|
12
|
+
|
|
13
|
+
The compiler still emits a local Lisp-truthiness helper for standalone
|
|
14
|
+
generated forms. `core/truth.mjs` exposes the same semantics to shared runtime
|
|
15
|
+
algorithms: only `false`, `null`, and `undefined` are false.
|
|
16
|
+
|
|
17
|
+
Host libraries are imported explicitly by application modules. The runtime
|
|
18
|
+
contains no UI-framework wrapper, element constructor, or bundler adapter.
|
|
19
|
+
|
|
20
|
+
## Modules
|
|
21
|
+
|
|
22
|
+
### Literal Runtime ABI
|
|
23
|
+
|
|
24
|
+
`literals.mjs` is the package-owned standard ESM link for generated persistent
|
|
25
|
+
constructors. It exports `list`, `vector`, `hashMap`, `hashSet`, `queue`,
|
|
26
|
+
`keyword`, and `symbol`,
|
|
27
|
+
delegating directly to the canonical persistent collection and identifier
|
|
28
|
+
implementations. The compiler imports it only when evaluated source or quoted
|
|
29
|
+
data constructs one of those runtime values. Static JavaScript property keys
|
|
30
|
+
and scalar-only quote do not link it by themselves. It has no application
|
|
31
|
+
framework, bundler, server, or publishing dependency. Explicit `js-array` and
|
|
32
|
+
`js-object` forms bypass this ABI and emit native containers directly;
|
|
33
|
+
`js-nth` and `js-length`
|
|
34
|
+
likewise bypass collection protocol dispatch.
|
|
35
|
+
|
|
36
|
+
### Persistent Vector
|
|
37
|
+
|
|
38
|
+
`core/vector.mjs` is the canonical provisional M8 persistent Vector module. It
|
|
39
|
+
implements an immutable 32-way bit-partitioned vector trie with a short tail
|
|
40
|
+
and now backs square-bracket value expressions. Internal
|
|
41
|
+
node shape, allocation, visit, and sharing observations are isolated in
|
|
42
|
+
`testing/vector.mjs`; applications must not depend on those test adapters.
|
|
43
|
+
`subvec` creates an O(1) range view that shares the complete source trie and
|
|
44
|
+
tail, flattens nested views, and retains Vector protocols, value semantics,
|
|
45
|
+
metadata, and selected-path updates without exposing hidden source values.
|
|
46
|
+
|
|
47
|
+
### Persistent List
|
|
48
|
+
|
|
49
|
+
`core/list.mjs` is the canonical optimized Persistent List runtime. Its frozen
|
|
50
|
+
singly linked nodes provide constant-time front construction, complete suffix
|
|
51
|
+
sharing, cached counts, iterative traversal, collection protocols, value
|
|
52
|
+
semantics, and immutable metadata. It deliberately does not advertise indexed
|
|
53
|
+
collection capability: its convenience `nth` method is linear-time. Internal
|
|
54
|
+
allocation and sharing observations live in `testing/list.mjs` and are not
|
|
55
|
+
application APIs.
|
|
56
|
+
|
|
57
|
+
### Persistent Queue
|
|
58
|
+
|
|
59
|
+
`core/queue.mjs` combines a persistent Vector front view with a persistent
|
|
60
|
+
Vector rear. Enqueue preserves the front; dequeue advances an O(1) subvector
|
|
61
|
+
view, and front exhaustion promotes the rear by identity without traversal or
|
|
62
|
+
node allocation. Queue values participate in collection protocols,
|
|
63
|
+
ordered value equality and hashing, immutable metadata, and iterative
|
|
64
|
+
million-scale traversal. Generated `(queue ...)` and `#queue [...]` forms use
|
|
65
|
+
the literal ABI, while canonical data text uses `#queue [...]`. Structural
|
|
66
|
+
observations are isolated in
|
|
67
|
+
`testing/queue.mjs`.
|
|
68
|
+
|
|
69
|
+
### Immutable Records
|
|
70
|
+
|
|
71
|
+
`core/record.mjs` defines exact immutable domain types over persistent HashMap
|
|
72
|
+
storage. `defrecord` generates positional and map constructors plus an exact
|
|
73
|
+
predicate; instances support property and Keyword lookup, persistent Map
|
|
74
|
+
updates and reduction, type-sensitive equality and hashing, immutable metadata,
|
|
75
|
+
and ordinary exact-type protocol extension. Removing an extra key preserves
|
|
76
|
+
the Record type, while removing a declared field returns a persistent HashMap.
|
|
77
|
+
The runtime has no framework or transport dependency; exact semantics are in
|
|
78
|
+
[0168](../specs/0168-immutable-record-types.md).
|
|
79
|
+
|
|
80
|
+
### Protocol Implementation Values
|
|
81
|
+
|
|
82
|
+
`core/type.mjs` provides exact low-level types with immutable positional
|
|
83
|
+
fields and frozen anonymous protocol values. `deftype` produces a type,
|
|
84
|
+
positional constructor, and exact predicate; `reify` produces a lexical
|
|
85
|
+
closure-backed identity object in expression position. Both install complete
|
|
86
|
+
direct protocol Symbol slots without changing global extension tables. Defined
|
|
87
|
+
types deliberately retain host identity semantics rather than Record value
|
|
88
|
+
semantics. Exact behavior is specified in
|
|
89
|
+
[0169](../specs/0169-protocol-implementation-values.md).
|
|
90
|
+
|
|
91
|
+
### Value Semantics
|
|
92
|
+
|
|
93
|
+
`core/value.mjs` defines provisional coercion-free value equality and unsigned
|
|
94
|
+
32-bit hashing. Portable scalar, List, and persistent-vector hashes are
|
|
95
|
+
deterministic;
|
|
96
|
+
opaque JavaScript objects retain process-local identity semantics. Persistent
|
|
97
|
+
hashes are cached privately. `testing/value.mjs` exposes cache and identity
|
|
98
|
+
counters only for conformance tests.
|
|
99
|
+
|
|
100
|
+
### Identifier Values
|
|
101
|
+
|
|
102
|
+
`core/identifier.mjs` defines immutable Keyword and Eliscript Symbol values
|
|
103
|
+
with optional namespaces. Keywords are interned; Symbols use field-based value
|
|
104
|
+
equality without interning. Both implement `IEquiv` and `IHash`, use distinct
|
|
105
|
+
deterministic category tags, and participate directly in persistent Map and
|
|
106
|
+
Set operations. A non-enumerable global logical-type brand lets portable
|
|
107
|
+
Eliscript value algorithms recognize the same categories without depending on
|
|
108
|
+
the runtime classes. The versioned Emacs worker value codec preserves both
|
|
109
|
+
identifier categories across the process boundary.
|
|
110
|
+
|
|
111
|
+
### Metadata
|
|
112
|
+
|
|
113
|
+
`core/metadata.mjs` defines open `IMeta` and `IWithMeta` protocols plus
|
|
114
|
+
`meta`, `withMeta`, `varyMeta`, and capability inspection. Eliscript Symbols
|
|
115
|
+
and persistent List, Vector, Map, and Set values attach either `null` or a
|
|
116
|
+
persistent Map by replacing only their frozen root wrapper. Equality and hashing ignore
|
|
117
|
+
metadata; collection updates, `empty`, and transient round trips preserve it;
|
|
118
|
+
logical host conversions emit only collection contents. Keywords remain
|
|
119
|
+
unannotated because their global interning cannot carry per-use state.
|
|
120
|
+
|
|
121
|
+
Exact semantics and evidence are specified in
|
|
122
|
+
[specs/0068-immutable-metadata-semantics.md](../specs/0068-immutable-metadata-semantics.md).
|
|
123
|
+
|
|
124
|
+
### Canonical Data Text
|
|
125
|
+
|
|
126
|
+
`core/data-text.mjs` supplies the open `IPrint` protocol and canonical
|
|
127
|
+
`printValue`, `readValue`, and `readValues` operations. Scalar edges,
|
|
128
|
+
identifiers, persistent List/Vector/Map/Set/Queue values, and metadata
|
|
129
|
+
round-trip through readable Lisp-shaped text. Map entries and Set members sort
|
|
130
|
+
by canonical text,
|
|
131
|
+
unsafe identifiers use explicit tags, and duplicate or malformed input fails
|
|
132
|
+
with a located `DataTextError`. Depth, UTF-16 length, and value-count limits
|
|
133
|
+
bound both directions.
|
|
134
|
+
|
|
135
|
+
This is deliberately separate from executable source reading and the future
|
|
136
|
+
versioned Emacs transport codec. Portable data text is implemented independently
|
|
137
|
+
in `stdlib/data-text.eli` over the same common grammar. Exact
|
|
138
|
+
semantics are specified in [0069](../specs/0069-canonical-runtime-data-text.md)
|
|
139
|
+
and [0071](../specs/0071-canonical-portable-data-text.md).
|
|
140
|
+
|
|
141
|
+
### Immutable Regex Text Processing
|
|
142
|
+
|
|
143
|
+
`core/regex.mjs` owns frozen opaque regex patterns and creates a fresh native
|
|
144
|
+
matcher for every operation. Stable `i`, `m`, `s`, and `u` flags are
|
|
145
|
+
canonicalized; stateful native flags are rejected. Full matching and offset
|
|
146
|
+
search return strings or persistent capture Vectors, memoized lazy scanning
|
|
147
|
+
handles zero-width Unicode matches without looping, and global replacement is
|
|
148
|
+
literal or callback-driven without exposing `lastIndex`. Exact semantics are
|
|
149
|
+
specified in [0178](../specs/0178-immutable-regex-text-processing.md).
|
|
150
|
+
|
|
151
|
+
### Persistent Map
|
|
152
|
+
|
|
153
|
+
`core/map.mjs` builds on that key contract with a provisional persistent HAMT.
|
|
154
|
+
Sparse bitmap nodes promote to dense 32-slot nodes, dense nodes compact after
|
|
155
|
+
deletion, and complete 32-bit collisions retain distinct keys. Internal node
|
|
156
|
+
shape, transition, allocation, visit, and sharing evidence lives in
|
|
157
|
+
`testing/map.mjs`. Cross-engine measurements select promotion at 32 occupied
|
|
158
|
+
branches and demotion at 24; the versioned methodology and baseline live under
|
|
159
|
+
`tools/collections` and `benchmarks`.
|
|
160
|
+
|
|
161
|
+
### Persistent Set
|
|
162
|
+
|
|
163
|
+
`core/set.mjs` is a thin immutable value-semantic view over that HAMT. Members
|
|
164
|
+
occupy map keys under one private sentinel, so Set membership, algebra,
|
|
165
|
+
collisions, and path sharing cannot drift from Map behavior. Set-specific
|
|
166
|
+
shape and sharing evidence is adapted through `testing/set.mjs` without
|
|
167
|
+
exposing the backing map to applications.
|
|
168
|
+
|
|
169
|
+
### Protocols and Collections
|
|
170
|
+
|
|
171
|
+
`core/protocol-impl.mjs` and its Source Map are generated from the canonical
|
|
172
|
+
`stdlib/core/protocol.eli` source by `bun run generate:runtime-protocol`.
|
|
173
|
+
`core/protocol.mjs` is a stable camel-case compatibility facade with no
|
|
174
|
+
dispatch policy of its own; `core/protocol-error.mjs` contains only the host
|
|
175
|
+
error type that cannot be expressed as an ordinary portable value.
|
|
176
|
+
|
|
177
|
+
`protocolDefinition` extracts a frozen
|
|
178
|
+
`eliscript-protocol-definition` v1 Object containing only a name and ordered
|
|
179
|
+
operation names. `defineProtocolFromDefinition` validates that data and creates
|
|
180
|
+
fresh local dispatch functions, Symbol slots, and empty extension state. The
|
|
181
|
+
definition can cross JSON and worker value boundaries; the executable protocol
|
|
182
|
+
object and its implementations cannot.
|
|
183
|
+
|
|
184
|
+
`core/collection.mjs` defines the generic collection capability layer:
|
|
185
|
+
`ICounted`, `IEmptyable`, `IConj`, `ILookup`, `IAssociative`, `IIndexed`,
|
|
186
|
+
`ISeqable`, `IReduce`, `IKVReduce`, `IMap`, `ISet`, `IStack`, and
|
|
187
|
+
`IReversible`. Persistent
|
|
188
|
+
List, Vector, Map, and Set values use direct Symbol slots; native Array, Map,
|
|
189
|
+
Set, and ordinary Object values use exact-type
|
|
190
|
+
extension tables, while primitive String uses an explicit host category.
|
|
191
|
+
Adapters do not modify prototypes. Sequence views are frozen and replayable;
|
|
192
|
+
bounded views expose finite counts, while explicitly unbounded views answer
|
|
193
|
+
`seq` without traversal and reject `count` immediately. Keyed elements are
|
|
194
|
+
frozen entries. Reduction views are frozen, replayable `IReduce`-only values
|
|
195
|
+
that reject `count` and `seq` without traversal. Reduced values provide early
|
|
196
|
+
termination, and construction operations preserve persistent inputs or return
|
|
197
|
+
immutable native copies.
|
|
198
|
+
|
|
199
|
+
`reduceKV` passes indexes or stored keys directly to a three-argument reducer.
|
|
200
|
+
Persistent Vector leaf arrays and persistent Map HAMT entries are traversed
|
|
201
|
+
without constructing public pair values; native Array, Map, Object, nil, and
|
|
202
|
+
externally extended values participate through the same open protocol.
|
|
203
|
+
|
|
204
|
+
`dissoc` and `disj` remove mappings or members without mutating inputs.
|
|
205
|
+
Persistent Map and Set values reuse HAMT paths, while native containers are
|
|
206
|
+
copied. `peek` and `pop` use the shared List head or the Vector/Array tail;
|
|
207
|
+
external values can implement each capability independently.
|
|
208
|
+
|
|
209
|
+
`rseq` returns a replayable reverse view for Persistent Vector, native Array,
|
|
210
|
+
String, and nil. Vector traversal caches one 32-value leaf at a time, allowing
|
|
211
|
+
`last` and `reverse` to avoid a complete forward copy.
|
|
212
|
+
|
|
213
|
+
### Transducers
|
|
214
|
+
|
|
215
|
+
`core/transducer.mjs` composes mapping, filtering, removing, bounded taking,
|
|
216
|
+
and dropping as destination-independent reducing-function transformations.
|
|
217
|
+
`transduce` delegates traversal through `IReduce`; `eduction` creates a
|
|
218
|
+
replayable reduction-only pipeline over finite or unbounded sources;
|
|
219
|
+
`runBang` performs ordered effectful consumption; and `into` obtains an empty
|
|
220
|
+
target and adds logical values through `IConj` or an editable transient
|
|
221
|
+
builder. Pipelines preserve reduced-value termination, run completion exactly
|
|
222
|
+
once, reuse transducers with fresh reduction state, and allocate no
|
|
223
|
+
intermediate collection.
|
|
224
|
+
|
|
225
|
+
### Transient Collections
|
|
226
|
+
|
|
227
|
+
`core/transient.mjs` defines provisional `IEditable` and
|
|
228
|
+
`ITransientCollection` protocols plus conversion and update operations.
|
|
229
|
+
Persistent Vector, Map, and Set values create owner-token builders that share
|
|
230
|
+
their source representation until the first selected-path update. Completion
|
|
231
|
+
returns a persistent value and permanently invalidates the builder. Transients
|
|
232
|
+
reject persistent collection operations and serialization; async and module
|
|
233
|
+
escape checks remain compiler work. Internal ownership and allocation evidence
|
|
234
|
+
is exposed only through `testing/vector.mjs`, `testing/map.mjs`, and
|
|
235
|
+
`testing/set.mjs`.
|
|
236
|
+
|
|
237
|
+
### Core Algorithms
|
|
238
|
+
|
|
239
|
+
`core/sequence.mjs` implements replayable range, repetition, iteration, cycle,
|
|
240
|
+
and indexed generation sources plus eager indexed/keep, prefix, sampling,
|
|
241
|
+
interposition, dedupe/distinct, flattening, partitioning, reduction-history,
|
|
242
|
+
boundary lookup, bounded tail selection, one-pass splitting, and search
|
|
243
|
+
operations against `IReduce`. Results are persistent Vectors, reduced values
|
|
244
|
+
stop bounded traversal exactly, and tail selection uses fixed-position ring
|
|
245
|
+
storage. Source callbacks are lazy, finite sources expose exact counts, and
|
|
246
|
+
unbounded sources compose with every reduced-value bounded consumer.
|
|
247
|
+
`core/data.mjs` implements
|
|
248
|
+
value-semantic indexing, grouping, counting, frequencies, nested associative
|
|
249
|
+
reads and updates, key selection, merging, and key/value zipping. Bulk result
|
|
250
|
+
construction uses persistent Maps and transient builders where prior-value
|
|
251
|
+
lookup is not required. Native and persistent collections, null, and external
|
|
252
|
+
protocol extensions all use the same algorithm path.
|
|
253
|
+
|
|
254
|
+
`core/order.mjs` defines the open `IComparable` protocol, deterministic
|
|
255
|
+
natural comparison for scalar, identifier, List, and Vector values, comparator
|
|
256
|
+
adaptation, stable `sort` and `sortBy`, and keyed extrema. Sorting consumes any
|
|
257
|
+
`IReduce` source, caches each sort key once, preserves equal-value source order,
|
|
258
|
+
and returns a persistent Vector without mutating its input.
|
|
259
|
+
|
|
260
|
+
`core/text-impl.mjs` and `core/object-impl.mjs` are generated from
|
|
261
|
+
`stdlib/core/text.eli` and `stdlib/core/object.eli`. Their public modules are
|
|
262
|
+
camel-case re-export facades. Text indexing uses UTF-16 code units throughout;
|
|
263
|
+
keyed transformations use protocols and transducer-backed `into`, selecting
|
|
264
|
+
transient construction for persistent Map targets without type branches.
|
|
265
|
+
|
|
266
|
+
`stdlib/core/protocol.eli`, `stdlib/core/seq.eli`, `stdlib/core/data.eli`,
|
|
267
|
+
`stdlib/core/order.eli`, `stdlib/core/text.eli`, and `stdlib/core/object.eli`
|
|
268
|
+
provide the maintained
|
|
269
|
+
Lisp-named Eliscript implementations. Protocol definitions and extension
|
|
270
|
+
tables remain process-local and are not serialized by the worker value codec.
|
|
271
|
+
|
|
272
|
+
### Worker Host
|
|
273
|
+
|
|
274
|
+
`worker.mjs` is the reference long-lived compute host. It communicates over
|
|
275
|
+
versioned NDJSON, imports local generated modules, correlates concurrent
|
|
276
|
+
requests, and supports progress, cooperative cancellation, timeouts, structured
|
|
277
|
+
errors, module caching, and shutdown. Protocol stdout is isolated from module
|
|
278
|
+
logs, which are redirected to stderr. Requests may address a raw generated ESM
|
|
279
|
+
export or resolve a `defportable` source name through the module's frozen
|
|
280
|
+
`__eliscript_portable__` manifest. `worker-value-codec.mjs` adds the explicit
|
|
281
|
+
`eliscript-value-v1` encoding for persistent values, identifiers, metadata,
|
|
282
|
+
special numeric/nullish values, and explicit native containers.
|
|
283
|
+
`worker-value-stream.mjs` adds `eliscript-value-chunks-v1`: an incremental
|
|
284
|
+
event grammar with bounded batches, persistent transient builders, traversal
|
|
285
|
+
limits, UTF-16-safe text parts, and cancellation checks. The worker applies
|
|
286
|
+
one-chunk acknowledgements to request input and stdout drain backpressure to
|
|
287
|
+
progress and response output. Chunked success timing reports actual argument
|
|
288
|
+
and response chunk counts plus the active framing bounds. The maintained
|
|
289
|
+
real-process probe binds its 256 MiB memory report to these runtime sources.
|
|
290
|
+
The worker also confines generated
|
|
291
|
+
`eliscript/runtime/` imports to this package runtime, so temporary portable
|
|
292
|
+
builds do not depend on their output directory for runtime resolution.
|
|
293
|
+
Request contexts now include a frozen `capabilities` token from
|
|
294
|
+
`platform/worker.mjs`, granting only progress and cancellation. The same
|
|
295
|
+
confined resolver accepts package-owned `eliscript/platform/` imports and
|
|
296
|
+
rejects traversal outside that directory.
|