hclang 0.20.0 → 0.20.2
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/esm/cli/hc.js +8 -2
- package/esm/lib/execute/lex-pipe.js +7 -0
- package/esm/lib/frames/bound-method.js +5 -5
- package/esm/lib/frames/evaluation-scope.js +30 -9
- package/esm/lib/frames/frame-alias.js +20 -19
- package/esm/lib/frames/frame-array.js +73 -35
- package/esm/lib/frames/frame-handle.js +51 -24
- package/esm/lib/frames/frame-string.js +12 -6
- package/esm/lib/frames/frame-symbol.js +8 -5
- package/esm/lib/frames/frame.js +49 -5
- package/esm/lib/frames/meta-frame.js +21 -0
- package/esm/lib/frames/resource-store.js +84 -0
- package/esm/lib/frames.js +1 -1
- package/esm/lib/modules/standard-modules.js +36 -0
- package/esm/lib/modules/standard-sources.js +366 -0
- package/esm/lib/version.js +1 -1
- package/package.json +1 -1
package/esm/cli/hc.js
CHANGED
|
@@ -9,6 +9,7 @@ import { parseArgs } from "../deps/jsr.io/@std/cli/1.0.32/parse_args.js";
|
|
|
9
9
|
import { runfile } from "./runfile.js";
|
|
10
10
|
import { Prompt } from "./prompt.js";
|
|
11
11
|
import { DenoFileStore } from "./resource-store.js";
|
|
12
|
+
import { withStandardModules } from "../lib/modules/standard-modules.js";
|
|
12
13
|
import { CLOCK_SCHEME, ClockHandler, Frame, FrameResource, RealClock, RESOURCE_ROOT_KEY, ResourceHandlers, } from "../lib/frames.js";
|
|
13
14
|
/**
|
|
14
15
|
* @module hc
|
|
@@ -46,7 +47,9 @@ export function getOptions(args) {
|
|
|
46
47
|
* identifier resolves against a fresh temp directory rather than against the
|
|
47
48
|
* working directory. That is a narrowing: the process still holds whatever the
|
|
48
49
|
* harness granted it, and the root binding is the ceiling the language enforces
|
|
49
|
-
* inside it.
|
|
50
|
+
* inside it. The root also overlays the read-only standard modules, so
|
|
51
|
+
* `'./modules/figures.hc'` reads the maintained Figures source and nothing else
|
|
52
|
+
* widens.
|
|
50
53
|
*
|
|
51
54
|
* @param env - An object containing key-value pairs of environment variables.
|
|
52
55
|
* @param out - Optional output sink. Tests inject a capture frame; the CLI uses HCLog.
|
|
@@ -60,6 +63,9 @@ export function getEval(env, out) {
|
|
|
60
63
|
/**
|
|
61
64
|
* Builds this harness's host namespace, root binding included.
|
|
62
65
|
*
|
|
66
|
+
* The root is a fresh temp directory with the read-only standard modules laid
|
|
67
|
+
* over it, so a program can import them without reaching anything else.
|
|
68
|
+
*
|
|
63
69
|
* Exported so a test can run a source unit under the authority the CLI actually
|
|
64
70
|
* grants, rather than under an empty namespace that would make the resource
|
|
65
71
|
* primitive invisible.
|
|
@@ -72,7 +78,7 @@ export function getHost(context = {}) {
|
|
|
72
78
|
// logger holds the same one: the root binding belongs to the host namespace
|
|
73
79
|
// and nowhere else.
|
|
74
80
|
const host = new Frame({ ...context });
|
|
75
|
-
host.set(RESOURCE_ROOT_KEY, FrameResource.root(new DenoFileStore(), getHandlers()));
|
|
81
|
+
host.set(RESOURCE_ROOT_KEY, FrameResource.root(withStandardModules(new DenoFileStore()), getHandlers()));
|
|
76
82
|
return host;
|
|
77
83
|
}
|
|
78
84
|
/**
|
|
@@ -74,6 +74,13 @@ export class LexPipe extends Frame {
|
|
|
74
74
|
if (parser.strictStructure && this.level !== 0) {
|
|
75
75
|
return this.structureFailure("unclosed", `${this.level}`);
|
|
76
76
|
}
|
|
77
|
+
// A line that ends inside an open structure ends a term, as a newline
|
|
78
|
+
// character does there, so a line-fed source and a character-fed one
|
|
79
|
+
// parse a multi-line aggregate alike rather than closing it row by row.
|
|
80
|
+
if (this.level !== 0) {
|
|
81
|
+
this.unbind().next(false);
|
|
82
|
+
return this;
|
|
83
|
+
}
|
|
77
84
|
const next_parser = this.unbind();
|
|
78
85
|
const output = FrameSymbol.end();
|
|
79
86
|
next_parser.call(output);
|
|
@@ -112,12 +112,12 @@ export class BoundMethod extends Frame {
|
|
|
112
112
|
}
|
|
113
113
|
return receiverState(this.receiverTarget, true, this.copyOnWrite, this.lexicalContext, true);
|
|
114
114
|
}
|
|
115
|
-
|
|
116
|
-
|
|
115
|
+
// Only the receiver is copied now. A member is copied when a write is
|
|
116
|
+
// about to land on it, so whatever the call never writes keeps its
|
|
117
|
+
// identity (#401).
|
|
118
|
+
const target = this.receiverTarget.instanceCopy();
|
|
117
119
|
const copyOnWrite = this.copyOnWrite ?? new WeakSet();
|
|
118
|
-
|
|
119
|
-
copyOnWrite.add(aggregate);
|
|
120
|
-
}
|
|
120
|
+
copyOnWrite.add(target);
|
|
121
121
|
return receiverState(target, true, copyOnWrite, this.lexicalContext, true);
|
|
122
122
|
}
|
|
123
123
|
}
|
|
@@ -9,7 +9,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
9
9
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
|
-
var _LiveLookupContext_lookupFrames, _LiveLookupContext_identityHandles, _EvaluationScope_lookupFrames, _EvaluationScope_lookupMembers;
|
|
12
|
+
var _LiveLookupContext_lookupFrames, _LiveLookupContext_identityHandles, _EvaluationScope_lookupFrames, _EvaluationScope_lookupMembers, _EvaluationScope_argumentLayer;
|
|
13
13
|
import { Frame } from "./frame.js";
|
|
14
14
|
import { FrameHandle } from "./frame-handle.js";
|
|
15
15
|
/** Live, read-only lookup through an ordered set of existing frame identities. */
|
|
@@ -28,7 +28,9 @@ class LiveLookupContext extends Frame {
|
|
|
28
28
|
}
|
|
29
29
|
resolve_here(key, _origin = this) {
|
|
30
30
|
for (const context of __classPrivateFieldGet(this, _LiveLookupContext_lookupFrames, "f")) {
|
|
31
|
-
|
|
31
|
+
// The same non-global graph as `lookup_here`, so a value and its binding
|
|
32
|
+
// agree; the outer resolve keeps the single global tier.
|
|
33
|
+
const binding = this.resolve_graph_on(context, key, context);
|
|
32
34
|
if (binding)
|
|
33
35
|
return binding;
|
|
34
36
|
}
|
|
@@ -36,7 +38,9 @@ class LiveLookupContext extends Frame {
|
|
|
36
38
|
}
|
|
37
39
|
lookup_here(key, _origin) {
|
|
38
40
|
for (const context of __classPrivateFieldGet(this, _LiveLookupContext_lookupFrames, "f")) {
|
|
39
|
-
|
|
41
|
+
// Non-global graph only: an operator falls through to the outer lookup's
|
|
42
|
+
// global tier, which curries it with that lookup's own operand.
|
|
43
|
+
const value = this.lookup_graph_on(context, key, context);
|
|
40
44
|
if (value.is.missing)
|
|
41
45
|
continue;
|
|
42
46
|
if (value instanceof FrameHandle) {
|
|
@@ -126,6 +130,7 @@ export class EvaluationScope {
|
|
|
126
130
|
});
|
|
127
131
|
_EvaluationScope_lookupFrames.set(this, void 0);
|
|
128
132
|
_EvaluationScope_lookupMembers.set(this, void 0);
|
|
133
|
+
_EvaluationScope_argumentLayer.set(this, void 0);
|
|
129
134
|
this.argument = options.argument;
|
|
130
135
|
this.parameter = options.parameter;
|
|
131
136
|
this.receiverState = options.receiverState;
|
|
@@ -138,6 +143,7 @@ export class EvaluationScope {
|
|
|
138
143
|
this.hostNamespace = options.hostNamespace;
|
|
139
144
|
__classPrivateFieldSet(this, _EvaluationScope_lookupFrames, options.lookupFrames, "f");
|
|
140
145
|
__classPrivateFieldSet(this, _EvaluationScope_lookupMembers, options.lookupMembers, "f");
|
|
146
|
+
__classPrivateFieldSet(this, _EvaluationScope_argumentLayer, options.argumentLayer, "f");
|
|
141
147
|
}
|
|
142
148
|
/** Creates the scope at the evaluator boundary. */
|
|
143
149
|
static root(fileScope, hostNamespace = Frame.nil) {
|
|
@@ -222,14 +228,18 @@ export class EvaluationScope {
|
|
|
222
228
|
const lookupFrames = [local, argument];
|
|
223
229
|
if (!parameter.is.void)
|
|
224
230
|
lookupFrames.push(parameter);
|
|
225
|
-
|
|
231
|
+
// A block nested in a method runs with the receiver state its method
|
|
232
|
+
// forwarded, and the enclosing method scope already holds the receiver
|
|
233
|
+
// layers behind the method's own locals. Pushing them again here would put
|
|
234
|
+
// the scope the receiver was read from ahead of those locals, so a caller
|
|
235
|
+
// that binds a local's name would capture it (#382 H11).
|
|
236
|
+
const forwarded = receiverState !== undefined &&
|
|
237
|
+
receiverState === enclosing?.receiverState;
|
|
238
|
+
if (receiverState && !forwarded) {
|
|
226
239
|
const receiverLookup = receiverState.lexicalContext
|
|
227
|
-
? new FrameHandle(receiverState.receiver, receiverState.mutable, receiverState.copyOnWrite, receiverState.lexicalContext
|
|
240
|
+
? new FrameHandle(receiverState.receiver, receiverState.mutable, receiverState.copyOnWrite, receiverState.lexicalContext)
|
|
228
241
|
: receiverState.receiver;
|
|
229
242
|
lookupFrames.push(receiverLookup);
|
|
230
|
-
if (receiverState.lexicalContext) {
|
|
231
|
-
lookupFrames.push(receiverState.lexicalContext);
|
|
232
|
-
}
|
|
233
243
|
}
|
|
234
244
|
if (closure)
|
|
235
245
|
lookupFrames.push(closure);
|
|
@@ -249,6 +259,7 @@ export class EvaluationScope {
|
|
|
249
259
|
writeTargetRole: targetRole,
|
|
250
260
|
lookupFrames: layers.frames,
|
|
251
261
|
lookupMembers: layers.members,
|
|
262
|
+
argumentLayer: argument,
|
|
252
263
|
enclosing,
|
|
253
264
|
closure,
|
|
254
265
|
lexicalTarget: target,
|
|
@@ -297,6 +308,7 @@ export class EvaluationScope {
|
|
|
297
308
|
writeTargetRole: this.writeTargetRole,
|
|
298
309
|
lookupFrames: layers.frames,
|
|
299
310
|
lookupMembers: layers.members,
|
|
311
|
+
argumentLayer: __classPrivateFieldGet(this, _EvaluationScope_argumentLayer, "f"),
|
|
300
312
|
enclosing: this.enclosing,
|
|
301
313
|
closure: this.closure,
|
|
302
314
|
lexicalTarget: this.lexicalTarget,
|
|
@@ -315,6 +327,7 @@ export class EvaluationScope {
|
|
|
315
327
|
writeTargetRole: role,
|
|
316
328
|
lookupFrames: layers.frames,
|
|
317
329
|
lookupMembers: layers.members,
|
|
330
|
+
argumentLayer: __classPrivateFieldGet(this, _EvaluationScope_argumentLayer, "f"),
|
|
318
331
|
enclosing: this.enclosing,
|
|
319
332
|
closure: this.closure,
|
|
320
333
|
lexicalTarget: target,
|
|
@@ -337,6 +350,14 @@ export class EvaluationScope {
|
|
|
337
350
|
lookupFrames() {
|
|
338
351
|
return __classPrivateFieldGet(this, _EvaluationScope_lookupFrames, "f");
|
|
339
352
|
}
|
|
353
|
+
/**
|
|
354
|
+
* Whether `layer` is this call's explicit argument, which lookup reads for
|
|
355
|
+
* its own and inherited properties only (spec 7, layer 2), never through the
|
|
356
|
+
* scope that built it.
|
|
357
|
+
*/
|
|
358
|
+
isArgumentLayer(layer) {
|
|
359
|
+
return layer === __classPrivateFieldGet(this, _EvaluationScope_argumentLayer, "f");
|
|
360
|
+
}
|
|
340
361
|
/** Resolves `_`, `__`, ... through enclosing call scopes. */
|
|
341
362
|
argumentAt(level) {
|
|
342
363
|
if (level <= 1)
|
|
@@ -452,4 +473,4 @@ export class EvaluationScope {
|
|
|
452
473
|
return { target: fallback, role: "statement" };
|
|
453
474
|
}
|
|
454
475
|
}
|
|
455
|
-
_EvaluationScope_lookupFrames = new WeakMap(), _EvaluationScope_lookupMembers = new WeakMap();
|
|
476
|
+
_EvaluationScope_lookupFrames = new WeakMap(), _EvaluationScope_lookupMembers = new WeakMap(), _EvaluationScope_argumentLayer = new WeakMap();
|
|
@@ -28,8 +28,9 @@ export class FrameAlias extends FrameAtom {
|
|
|
28
28
|
scope.lookupFrames().find((context) => context instanceof FrameLazy) ??
|
|
29
29
|
scope.argument;
|
|
30
30
|
// Receiver and declared-parent hits are writes to object state, so they
|
|
31
|
-
// require the method capability. A miss searches the
|
|
32
|
-
//
|
|
31
|
+
// require the method capability. A miss searches the method's own scope and
|
|
32
|
+
// the scope it was written in, never the scope its receiver was read from
|
|
33
|
+
// (#400) and never caller-owned argument or parameter values.
|
|
33
34
|
const receiverFound = receiver
|
|
34
35
|
? this.find(receiver, key, origin, new Set(), false)
|
|
35
36
|
: undefined;
|
|
@@ -43,13 +44,19 @@ export class FrameAlias extends FrameAtom {
|
|
|
43
44
|
return this.setterFor(receiverFound, key, receiverState?.copyOnWrite);
|
|
44
45
|
}
|
|
45
46
|
if (receiver) {
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const seen = new Set();
|
|
48
|
+
for (const context of scope.lookupFrames()) {
|
|
49
|
+
if (context === scope.argument || context === scope.parameter ||
|
|
50
|
+
context.referent() === receiver)
|
|
51
|
+
continue;
|
|
52
|
+
const lexicalFound = this.find(context, key, origin, seen);
|
|
53
|
+
if (lexicalFound instanceof Frame)
|
|
54
|
+
return lexicalFound;
|
|
55
|
+
if (lexicalFound) {
|
|
56
|
+
return this.setterFor(lexicalFound, key, receiverState?.copyOnWrite);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return FrameNote.key(key, this);
|
|
53
60
|
}
|
|
54
61
|
for (const context of scope.lookupFrames()) {
|
|
55
62
|
const found = this.find(context, key, origin);
|
|
@@ -73,17 +80,11 @@ export class FrameAlias extends FrameAtom {
|
|
|
73
80
|
return undefined;
|
|
74
81
|
}
|
|
75
82
|
seen.add(context);
|
|
76
|
-
// A
|
|
77
|
-
// the
|
|
78
|
-
//
|
|
79
|
-
// invocation.
|
|
83
|
+
// A handle created by a read reaches its target and declared parents only:
|
|
84
|
+
// neither the target's historical `up`, which belongs to neither this
|
|
85
|
+
// receiver nor this invocation, nor the scope of the read (#400).
|
|
80
86
|
if (context instanceof FrameHandle && context.readContextFrame()) {
|
|
81
|
-
|
|
82
|
-
if (targetFound)
|
|
83
|
-
return targetFound;
|
|
84
|
-
return followLexical
|
|
85
|
-
? this.find(context.readContextFrame(), key, origin, seen)
|
|
86
|
-
: undefined;
|
|
87
|
+
return this.find(context.unwrap(), key, origin, seen, false, true);
|
|
87
88
|
}
|
|
88
89
|
const binding = context.resolve_here(key, origin);
|
|
89
90
|
if (binding?.value.is.error) {
|
|
@@ -107,25 +107,26 @@ export class FrameArray extends FrameList {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
115
|
-
* own field, and the id is always fresh.
|
|
110
|
+
* An instance copy is a fresh aggregate whose members are shared, so a
|
|
111
|
+
* member keeps its identity until a write is about to land on it. Copy on
|
|
112
|
+
* write copies that member then, into the copy that holds it
|
|
113
|
+
* (`FrameHandle.copyOnWriteTarget`, #401), so writing through the copy is
|
|
114
|
+
* still invisible through the original at any depth. A declared parent rides
|
|
115
|
+
* along in its own field, and the id is always fresh.
|
|
116
116
|
*/
|
|
117
|
-
instanceCopy(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
117
|
+
instanceCopy() {
|
|
118
|
+
return this.copy();
|
|
119
|
+
}
|
|
120
|
+
/** Elements are members too, so a held element can be replaced in place. */
|
|
121
|
+
replaceMember(member, replacement) {
|
|
122
|
+
let replaced = super.replaceMember(member, replacement);
|
|
123
|
+
this.data = this.data.map((item) => {
|
|
124
|
+
if (item !== member)
|
|
125
|
+
return item;
|
|
126
|
+
replaced = true;
|
|
127
|
+
return replacement;
|
|
128
|
+
});
|
|
129
|
+
return replaced;
|
|
129
130
|
}
|
|
130
131
|
lookup_here(key, origin) {
|
|
131
132
|
if (/^\d+$/.test(key)) {
|
|
@@ -152,19 +153,45 @@ export class FrameArray extends FrameList {
|
|
|
152
153
|
*/
|
|
153
154
|
applicationMethod() {
|
|
154
155
|
for (const key of FrameArray.APPLICATION_KEYS) {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
while (local.is.missing && next && !seen.has(next)) {
|
|
159
|
-
seen.add(next);
|
|
160
|
-
local = next.get_here(key);
|
|
161
|
-
next = next.hasDeclaredParent() ? next.parent : undefined;
|
|
162
|
-
}
|
|
163
|
-
if (local.className() === "FrameLazy")
|
|
164
|
-
return { key, method: local };
|
|
156
|
+
const method = this.declaredMethod(key);
|
|
157
|
+
if (method)
|
|
158
|
+
return { key, method };
|
|
165
159
|
}
|
|
166
160
|
return undefined;
|
|
167
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* What this aggregate contributes when text receives it (#398).
|
|
164
|
+
*
|
|
165
|
+
* Text contributes an aggregate's spelling, which reads back as the same
|
|
166
|
+
* value but spells every declaration, methods included. An aggregate that
|
|
167
|
+
* declares `toText`, on itself or a declared parent, contributes that
|
|
168
|
+
* method's answer instead, the way one that declares `apply` decides its own
|
|
169
|
+
* application. The printer never calls it, so a printed value still reads
|
|
170
|
+
* back.
|
|
171
|
+
*/
|
|
172
|
+
toText() {
|
|
173
|
+
const method = this.declaredMethod(FrameArray.TEXT_KEY);
|
|
174
|
+
if (!method)
|
|
175
|
+
return this;
|
|
176
|
+
return new BoundMethod(method, this, false, methodEffect(FrameArray.TEXT_KEY)).call(Frame.nil);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* A method declared under `key` on this aggregate or its declared parents.
|
|
180
|
+
*
|
|
181
|
+
* Never the scope around it, so a plain array keeps its default behavior
|
|
182
|
+
* wherever it is written.
|
|
183
|
+
*/
|
|
184
|
+
declaredMethod(key) {
|
|
185
|
+
const seen = new Set([this]);
|
|
186
|
+
let local = this.get_here(key);
|
|
187
|
+
let next = this.hasDeclaredParent() ? this.parent : undefined;
|
|
188
|
+
while (local.is.missing && next && !seen.has(next)) {
|
|
189
|
+
seen.add(next);
|
|
190
|
+
local = next.get_here(key);
|
|
191
|
+
next = next.hasDeclaredParent() ? next.parent : undefined;
|
|
192
|
+
}
|
|
193
|
+
return local.className() === "FrameLazy" ? local : undefined;
|
|
194
|
+
}
|
|
168
195
|
/**
|
|
169
196
|
* Runs a declared application with the receiver it binds to.
|
|
170
197
|
*
|
|
@@ -201,16 +228,20 @@ export class FrameArray extends FrameList {
|
|
|
201
228
|
}
|
|
202
229
|
return this;
|
|
203
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* The element at `index`, counting from the end when negative.
|
|
233
|
+
*
|
|
234
|
+
* An index addresses the element plane, the one `&` iterates, so declaring a
|
|
235
|
+
* property never shifts an element's index: `[.k 1; 4, 5] .0` is `4`.
|
|
236
|
+
*/
|
|
204
237
|
at(index) {
|
|
205
|
-
|
|
206
|
-
|
|
238
|
+
const elements = this.elements();
|
|
239
|
+
const n = elements.length;
|
|
240
|
+
if (index >= n || -index > n) {
|
|
241
|
+
const source = "[0.." + n + "]." + index;
|
|
207
242
|
return FrameNote.index(source);
|
|
208
243
|
}
|
|
209
|
-
|
|
210
|
-
return this.data[index];
|
|
211
|
-
}
|
|
212
|
-
const n = this.data.length;
|
|
213
|
-
return this.data[n + index];
|
|
244
|
+
return elements[index >= 0 ? index : n + index];
|
|
214
245
|
}
|
|
215
246
|
length() {
|
|
216
247
|
return this.data.length;
|
|
@@ -254,3 +285,10 @@ Object.defineProperty(FrameArray, "APPLICATION_KEYS", {
|
|
|
254
285
|
writable: true,
|
|
255
286
|
value: ["apply_", "apply"]
|
|
256
287
|
});
|
|
288
|
+
/** The key an aggregate declares its readable text under (#398). */
|
|
289
|
+
Object.defineProperty(FrameArray, "TEXT_KEY", {
|
|
290
|
+
enumerable: true,
|
|
291
|
+
configurable: true,
|
|
292
|
+
writable: true,
|
|
293
|
+
value: "toText"
|
|
294
|
+
});
|
|
@@ -12,17 +12,18 @@ import { methodEffect } from "./effect-marker.js";
|
|
|
12
12
|
* views, and application all delegate to the target. A handle is invisible to
|
|
13
13
|
* comparison, and assignment unwraps it, so a mutation lands on the same
|
|
14
14
|
* frame it would have without the wrapper.
|
|
15
|
-
* - **
|
|
16
|
-
* read
|
|
17
|
-
*
|
|
18
|
-
* the
|
|
19
|
-
* handles without a read context retain their original target
|
|
15
|
+
* - **Target lookup.** A handle created by symbol lookup records the scope it
|
|
16
|
+
* was read in, for that read's evaluation roots only. Lookup stays live on
|
|
17
|
+
* the target and its declared parents and never falls back to that scope, so
|
|
18
|
+
* the path a value was reached by supplies no names (#400). Legacy
|
|
19
|
+
* programmatic handles without a read context retain their original target
|
|
20
|
+
* traversal.
|
|
20
21
|
*
|
|
21
22
|
* Discovering a method here yields a `BoundMethod`; the effect rules for that
|
|
22
23
|
* pairing belong to it, not to the handle.
|
|
23
24
|
*/
|
|
24
25
|
export class FrameHandle extends Frame {
|
|
25
|
-
constructor(target, mutable, copyOnWrite, readContext
|
|
26
|
+
constructor(target, mutable, copyOnWrite, readContext) {
|
|
26
27
|
super();
|
|
27
28
|
Object.defineProperty(this, "target", {
|
|
28
29
|
enumerable: true,
|
|
@@ -48,11 +49,12 @@ export class FrameHandle extends Frame {
|
|
|
48
49
|
writable: true,
|
|
49
50
|
value: readContext
|
|
50
51
|
});
|
|
51
|
-
|
|
52
|
+
/** What this handle was read from during a functional update (#401). */
|
|
53
|
+
Object.defineProperty(this, "holder", {
|
|
52
54
|
enumerable: true,
|
|
53
55
|
configurable: true,
|
|
54
56
|
writable: true,
|
|
55
|
-
value:
|
|
57
|
+
value: void 0
|
|
56
58
|
});
|
|
57
59
|
// Preserve the historical programmatic link. Contextual lookup overrides
|
|
58
60
|
// traversal below, so a shared target never needs to acquire this context.
|
|
@@ -61,6 +63,41 @@ export class FrameHandle extends Frame {
|
|
|
61
63
|
unwrap() {
|
|
62
64
|
return this.target;
|
|
63
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Records what this handle was read from, so a write through it during a
|
|
68
|
+
* functional update can copy the path down to its target.
|
|
69
|
+
*/
|
|
70
|
+
heldBy(holder) {
|
|
71
|
+
this.holder = holder;
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The target a write through this handle may land on during a functional
|
|
76
|
+
* update, copied into the copy-on-write graph first (#401).
|
|
77
|
+
*
|
|
78
|
+
* A functional update copies only its receiver. When a write is about to
|
|
79
|
+
* reach a member the call has not copied yet, that member is copied now and
|
|
80
|
+
* installed in the copy that holds it, copying that holder first if it too
|
|
81
|
+
* is still shared, and this handle follows the copy. A target reached
|
|
82
|
+
* through a shared declared parent has no copied holder, so it answers
|
|
83
|
+
* nothing and the write meets `$!.copy-on-write-boundary`.
|
|
84
|
+
*/
|
|
85
|
+
copyOnWriteTarget() {
|
|
86
|
+
const graph = this.copyOnWrite;
|
|
87
|
+
if (!graph || graph.has(this.target))
|
|
88
|
+
return this.target;
|
|
89
|
+
const holder = this.holder instanceof FrameHandle
|
|
90
|
+
? this.holder.copyOnWriteTarget()
|
|
91
|
+
: this.holder;
|
|
92
|
+
if (!holder || !graph.has(holder))
|
|
93
|
+
return undefined;
|
|
94
|
+
const copy = this.target.instanceCopy();
|
|
95
|
+
if (!holder.replaceMember(this.target, copy))
|
|
96
|
+
return undefined;
|
|
97
|
+
graph.add(copy);
|
|
98
|
+
this.target = copy;
|
|
99
|
+
return copy;
|
|
100
|
+
}
|
|
64
101
|
/** A handle is transparent to equality: it compares as its target. */
|
|
65
102
|
referent() {
|
|
66
103
|
return this.target.referent();
|
|
@@ -78,25 +115,16 @@ export class FrameHandle extends Frame {
|
|
|
78
115
|
/** Retains this live reference while withholding its write capability. */
|
|
79
116
|
withoutWriteAuthority() {
|
|
80
117
|
return this.mutable
|
|
81
|
-
? new FrameHandle(this.target, false, this.copyOnWrite, this.readContext
|
|
118
|
+
? new FrameHandle(this.target, false, this.copyOnWrite, this.readContext)
|
|
82
119
|
: this;
|
|
83
120
|
}
|
|
84
|
-
/** The
|
|
121
|
+
/** The scope this read happened in, which supplies roots but never names. */
|
|
85
122
|
readContextFrame() {
|
|
86
123
|
return this.readContext;
|
|
87
124
|
}
|
|
88
125
|
evaluationRoots() {
|
|
89
126
|
return this.readContext?.evaluationRoots();
|
|
90
127
|
}
|
|
91
|
-
/**
|
|
92
|
-
* Context to persist on a value returned through this handle.
|
|
93
|
-
*
|
|
94
|
-
* A receiver-only handle restricts one lookup operation; that restriction
|
|
95
|
-
* must not truncate the caller-specific continuation of a returned value.
|
|
96
|
-
*/
|
|
97
|
-
resultContext() {
|
|
98
|
-
return this.searchReadContext ? this : new FrameHandle(this.target, this.mutable, this.copyOnWrite, this.readContext);
|
|
99
|
-
}
|
|
100
128
|
/** Copy provenance carried across dotted aggregate traversal. */
|
|
101
129
|
copyOnWriteScope() {
|
|
102
130
|
return this.copyOnWrite;
|
|
@@ -113,15 +141,14 @@ export class FrameHandle extends Frame {
|
|
|
113
141
|
const links = [];
|
|
114
142
|
if (this.target.hasDeclaredParent())
|
|
115
143
|
links.push(this.target.parent);
|
|
116
|
-
if (this.searchReadContext && this.readContext !== this.target &&
|
|
117
|
-
!links.includes(this.readContext)) {
|
|
118
|
-
links.push(this.readContext);
|
|
119
|
-
}
|
|
120
144
|
return links;
|
|
121
145
|
}
|
|
122
146
|
lookup_result(value, key) {
|
|
123
147
|
if (value instanceof FrameLazy) {
|
|
124
|
-
|
|
148
|
+
const effect = methodEffect(key);
|
|
149
|
+
if (effect.mutating && this.mutable)
|
|
150
|
+
this.copyOnWriteTarget();
|
|
151
|
+
return new BoundMethod(value, this.target, this.mutable, effect, this.copyOnWrite, this.readContext);
|
|
125
152
|
}
|
|
126
153
|
return value;
|
|
127
154
|
}
|
|
@@ -11,15 +11,21 @@ const reducer = (current, char) => {
|
|
|
11
11
|
return result;
|
|
12
12
|
};
|
|
13
13
|
/**
|
|
14
|
-
* Joins one text value with a juxtaposed argument,
|
|
14
|
+
* Joins one text value with a juxtaposed argument, yielding a string.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
16
|
+
* The argument contributes what its `toText` answers, which is itself unless
|
|
17
|
+
* an aggregate declared one (#398). Character content contributes its
|
|
18
|
+
* characters; anything else contributes its spelling, so `“a” #c# ` keeps the
|
|
19
|
+
* comment delimiters it was written with. A refusal from a declared `toText`
|
|
20
|
+
* stays a refusal rather than being spelled into the text.
|
|
18
21
|
*/
|
|
19
22
|
export const concatenateText = (receiver, argument) => {
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
const text = argument.referent().toText();
|
|
24
|
+
if (text !== argument.referent() && text.isFailedResult())
|
|
25
|
+
return text;
|
|
26
|
+
const value = hasCharacterContent(text)
|
|
27
|
+
? text.characterContent()
|
|
28
|
+
: text.toString();
|
|
23
29
|
return new FrameString(receiver.characterContent() + value);
|
|
24
30
|
};
|
|
25
31
|
/**
|
|
@@ -97,7 +97,9 @@ export class FrameSymbol extends FrameAtom {
|
|
|
97
97
|
(context instanceof FrameHandle && !explicitOrigin.is.missing
|
|
98
98
|
? explicitOrigin
|
|
99
99
|
: context);
|
|
100
|
-
const value =
|
|
100
|
+
const value = scope.isArgumentLayer(context)
|
|
101
|
+
? context.getOwn(this.data, origin)
|
|
102
|
+
: context.get(this.data, origin);
|
|
101
103
|
if (!value.is.missing) {
|
|
102
104
|
if (value.is.error)
|
|
103
105
|
return value;
|
|
@@ -107,7 +109,7 @@ export class FrameSymbol extends FrameAtom {
|
|
|
107
109
|
// re-parented for the benefit of one reader.
|
|
108
110
|
const isCanonicalBoolean = value === Frame.nil || value === Frame.all;
|
|
109
111
|
const continuation = context instanceof FrameHandle
|
|
110
|
-
? context
|
|
112
|
+
? context
|
|
111
113
|
: context.projectionContext();
|
|
112
114
|
const resolved = value instanceof FrameLazy
|
|
113
115
|
? value.bind(scope.captureScope())
|
|
@@ -135,9 +137,10 @@ export class FrameSymbol extends FrameAtom {
|
|
|
135
137
|
const copyOnWrite = context instanceof FrameHandle
|
|
136
138
|
? context.copyOnWriteScope() ?? receiverState?.copyOnWrite
|
|
137
139
|
: receiverState?.copyOnWrite;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
if (!(resolved instanceof FrameArray))
|
|
141
|
+
return resolved;
|
|
142
|
+
const handle = new FrameHandle(resolved, touchesIdentity(this.data), copyOnWrite, continuation);
|
|
143
|
+
return copyOnWrite ? handle.heldBy(context) : handle;
|
|
141
144
|
}
|
|
142
145
|
}
|
|
143
146
|
return FrameNote.key(first.id + "." + this.data, first);
|
package/esm/lib/frames/frame.js
CHANGED
|
@@ -210,6 +210,28 @@ export class Frame extends MetaFrame {
|
|
|
210
210
|
referent() {
|
|
211
211
|
return this;
|
|
212
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Get a frame by key from this frame's own properties and its declared
|
|
215
|
+
* parents only, never its lexical scope.
|
|
216
|
+
*
|
|
217
|
+
* This is how a call reads its explicit argument (spec 7, layer 2). The
|
|
218
|
+
* argument's lexical scope is wherever that value was built, which the
|
|
219
|
+
* closure did not choose, so following it would let any scope that built an
|
|
220
|
+
* argument bind the closure's names. A handle reads its target, and still
|
|
221
|
+
* binds a method it finds to that target.
|
|
222
|
+
*/
|
|
223
|
+
getOwn(key, origin = this) {
|
|
224
|
+
const seen = new Set();
|
|
225
|
+
let frame = this.referent();
|
|
226
|
+
while (frame && !seen.has(frame)) {
|
|
227
|
+
seen.add(frame);
|
|
228
|
+
const local = frame.lookup_here(key, origin);
|
|
229
|
+
if (!local.is.missing)
|
|
230
|
+
return this.lookup_result(local, key);
|
|
231
|
+
frame = frame.hasDeclaredParent() ? frame.parent : undefined;
|
|
232
|
+
}
|
|
233
|
+
return Frame.missing;
|
|
234
|
+
}
|
|
213
235
|
/** Whether a write can land on this frame, so that identity is observable. */
|
|
214
236
|
ownsIdentity() {
|
|
215
237
|
return false;
|
|
@@ -335,6 +357,16 @@ export class Frame extends MetaFrame {
|
|
|
335
357
|
applicationMethod() {
|
|
336
358
|
return undefined;
|
|
337
359
|
}
|
|
360
|
+
/**
|
|
361
|
+
* What this frame contributes when text receives it (#398).
|
|
362
|
+
*
|
|
363
|
+
* A frame contributes itself, so text takes its characters or its spelling.
|
|
364
|
+
* An aggregate may declare `toText` to answer something more readable; see
|
|
365
|
+
* `FrameArray.toText`.
|
|
366
|
+
*/
|
|
367
|
+
toText() {
|
|
368
|
+
return this;
|
|
369
|
+
}
|
|
338
370
|
/**
|
|
339
371
|
* The values this frame streams when it is iterated.
|
|
340
372
|
*
|
|
@@ -421,14 +453,26 @@ export class Frame extends MetaFrame {
|
|
|
421
453
|
* shields an immutable receiver from a mutating method. Atoms are immutable
|
|
422
454
|
* and closures are shared bodies, so for them sharing is unobservable and the
|
|
423
455
|
* default is to share. Aggregates own identity, so `FrameArray` overrides this
|
|
424
|
-
* to hand back a fresh
|
|
425
|
-
*
|
|
426
|
-
* The map memoizes aggregates already copied in this operation, so a nested
|
|
427
|
-
* aggregate reached twice stays one aggregate and a cyclic chain terminates.
|
|
456
|
+
* to hand back a fresh aggregate whose members are still shared (#401).
|
|
428
457
|
*/
|
|
429
|
-
instanceCopy(
|
|
458
|
+
instanceCopy() {
|
|
430
459
|
return this;
|
|
431
460
|
}
|
|
461
|
+
/**
|
|
462
|
+
* Replaces a member that is exactly `member` with `replacement`, answering
|
|
463
|
+
* whether one was found. Copy-on-write uses it to install a copy of a member
|
|
464
|
+
* into the copy that holds it, so only declared slots are searched here.
|
|
465
|
+
*/
|
|
466
|
+
replaceMember(member, replacement) {
|
|
467
|
+
let replaced = false;
|
|
468
|
+
for (const [key, value] of this.meta_pairs()) {
|
|
469
|
+
if (value === member) {
|
|
470
|
+
this.meta[key] = replacement;
|
|
471
|
+
replaced = true;
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
return replaced;
|
|
475
|
+
}
|
|
432
476
|
/**
|
|
433
477
|
* Negation is decided by the symbol's name, never by how it prints.
|
|
434
478
|
*
|
|
@@ -108,6 +108,27 @@ export class MetaFrame {
|
|
|
108
108
|
lookup_here_on(frame, key, origin) {
|
|
109
109
|
return frame.lookup_here(key, origin);
|
|
110
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Lets a forwarding link search another frame's non-global lookup graph.
|
|
113
|
+
*
|
|
114
|
+
* `Frame.globals` stays the one final tier of the outer `get`, which
|
|
115
|
+
* curries an operator with that lookup's own origin; a forwarded `get`
|
|
116
|
+
* would reach the globals early, from the wrong frame.
|
|
117
|
+
*/
|
|
118
|
+
lookup_graph_on(frame, key, origin) {
|
|
119
|
+
return MetaFrame.lookup(frame, key, origin, new Set());
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Lets a forwarding link resolve a binding through another frame's
|
|
123
|
+
* non-global graph.
|
|
124
|
+
*
|
|
125
|
+
* The binding counterpart of `lookup_graph_on`, with the same tiers, so a
|
|
126
|
+
* forwarded value and its binding metadata come from the same declaration
|
|
127
|
+
* owner. `Frame.globals` stays the one final tier of the outer `resolve`.
|
|
128
|
+
*/
|
|
129
|
+
resolve_graph_on(frame, key, origin) {
|
|
130
|
+
return MetaFrame.resolveBinding(frame, key, origin, new Set());
|
|
131
|
+
}
|
|
111
132
|
/** Resolves a logical name to the declaration key visible from origin. */
|
|
112
133
|
resolve_here(key, origin = this) {
|
|
113
134
|
if (key.startsWith("__")) {
|
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _ResourceMapStore_entries;
|
|
1
13
|
/**
|
|
2
14
|
* The host seam a root binding holds.
|
|
3
15
|
*
|
|
@@ -13,6 +25,7 @@
|
|
|
13
25
|
*
|
|
14
26
|
* @module
|
|
15
27
|
*/
|
|
28
|
+
import { normalizeReferencePath } from "./resource-reference.js";
|
|
16
29
|
/**
|
|
17
30
|
* A store with no host behind it at all.
|
|
18
31
|
*
|
|
@@ -50,3 +63,74 @@ export class MemoryStore {
|
|
|
50
63
|
return { ok: true, content };
|
|
51
64
|
}
|
|
52
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The copies `canonicalEntries` made. None escapes this module except through
|
|
68
|
+
* `ResourceMapStore.overlay`, which hands it only back to the constructor, so a
|
|
69
|
+
* member is already checked and no caller can change it.
|
|
70
|
+
*/
|
|
71
|
+
const CANONICAL = new WeakSet();
|
|
72
|
+
/** Checks every key is a canonical nonempty path, and copies the entries. */
|
|
73
|
+
function canonicalEntries(entries) {
|
|
74
|
+
if (CANONICAL.has(entries))
|
|
75
|
+
return entries;
|
|
76
|
+
const copied = new Map();
|
|
77
|
+
for (const [key, content] of entries) {
|
|
78
|
+
const normal = normalizeReferencePath(key);
|
|
79
|
+
if (key === "" || !normal.ok || normal.path !== key) {
|
|
80
|
+
throw new TypeError(`ResourceMapStore key must be a canonical nonempty path: ${JSON.stringify(key)}`);
|
|
81
|
+
}
|
|
82
|
+
copied.set(key, content);
|
|
83
|
+
}
|
|
84
|
+
CANONICAL.add(copied);
|
|
85
|
+
return copied;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* A read-only overlay of fixed entries, keyed by canonical root-relative path,
|
|
89
|
+
* on another store.
|
|
90
|
+
*
|
|
91
|
+
* A harness uses it to serve package-owned HC source without widening its root:
|
|
92
|
+
* exact keys read their entry and refuse writes, and every other path, plus
|
|
93
|
+
* `describe`, is the underlying store's. Keys are checked once, here, so only a
|
|
94
|
+
* path the root plane itself would produce can be installed; a key that fails is
|
|
95
|
+
* a harness defect, and the constructor throws rather than refusing. The entries
|
|
96
|
+
* are copied, so the caller's map cannot change what the overlay serves.
|
|
97
|
+
* `overlay` checks and copies once for a harness that lays the same entries over
|
|
98
|
+
* many stores.
|
|
99
|
+
*/
|
|
100
|
+
export class ResourceMapStore {
|
|
101
|
+
constructor(underlying, entries) {
|
|
102
|
+
Object.defineProperty(this, "underlying", {
|
|
103
|
+
enumerable: true,
|
|
104
|
+
configurable: true,
|
|
105
|
+
writable: true,
|
|
106
|
+
value: underlying
|
|
107
|
+
});
|
|
108
|
+
_ResourceMapStore_entries.set(this, void 0);
|
|
109
|
+
__classPrivateFieldSet(this, _ResourceMapStore_entries, canonicalEntries(entries), "f");
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Checks and copies fixed entries once, for laying over any number of stores.
|
|
113
|
+
*
|
|
114
|
+
* @param entries The fixed entries, by canonical root-relative path.
|
|
115
|
+
* @returns A function that lays those entries over a store.
|
|
116
|
+
*/
|
|
117
|
+
static overlay(entries) {
|
|
118
|
+
const fixed = canonicalEntries(entries);
|
|
119
|
+
return (underlying) => new ResourceMapStore(underlying, fixed);
|
|
120
|
+
}
|
|
121
|
+
describe() {
|
|
122
|
+
return this.underlying.describe();
|
|
123
|
+
}
|
|
124
|
+
read(path) {
|
|
125
|
+
const content = __classPrivateFieldGet(this, _ResourceMapStore_entries, "f").get(path);
|
|
126
|
+
return content === undefined
|
|
127
|
+
? this.underlying.read(path)
|
|
128
|
+
: { ok: true, content };
|
|
129
|
+
}
|
|
130
|
+
write(path, content) {
|
|
131
|
+
return __classPrivateFieldGet(this, _ResourceMapStore_entries, "f").has(path)
|
|
132
|
+
? { ok: false, reason: "resource-read-only" }
|
|
133
|
+
: this.underlying.write(path, content);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
_ResourceMapStore_entries = new WeakMap();
|
package/esm/lib/frames.js
CHANGED
|
@@ -41,7 +41,7 @@ export { FrameResource } from "./frames/frame-resource.js";
|
|
|
41
41
|
export { isResourceBinding, RESOURCE_ROOT_KEY, } from "./frames/resource-binding.js";
|
|
42
42
|
export { containsResolved, decomposeReference, joinNormalized, normalizeReference, normalizeReferencePath, URI_PART_KEYS, } from "./frames/resource-reference.js";
|
|
43
43
|
export { characterElements, ResourceHandlers, StoreHandler, } from "./frames/resource-handlers.js";
|
|
44
|
-
export { MemoryStore, } from "./frames/resource-store.js";
|
|
44
|
+
export { MemoryStore, ResourceMapStore, } from "./frames/resource-store.js";
|
|
45
45
|
export { Frame, } from "./frames/frame.js";
|
|
46
46
|
export { MetaFrame, Visibility } from "./frames/meta-frame.js";
|
|
47
47
|
export { ScanDisposition, } from "./scan.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The standard modules every supported host serves, read-only, under canonical
|
|
3
|
+
* keys.
|
|
4
|
+
*
|
|
5
|
+
* A standard module is HC source the package maintains: every
|
|
6
|
+
* `lib/modules/*.hc` is one, under the key `modules/<file>`, so
|
|
7
|
+
* `lib/modules/figures.hc` is reached from a program as
|
|
8
|
+
* `'./modules/figures.hc'`. The key is root-relative like every other path, so
|
|
9
|
+
* it names a location inside the root binding, never one beside a source file
|
|
10
|
+
* or the working directory. A host lays the modules over its root's store as
|
|
11
|
+
* fixed entries: reading one answers the maintained source, writing one is
|
|
12
|
+
* refused, and every other path, a sibling under `modules/` included, still
|
|
13
|
+
* resolves inside that root. No permission flag and no root widens, so a program
|
|
14
|
+
* gains these reads and nothing else.
|
|
15
|
+
*
|
|
16
|
+
* The sources are compiled into the program from the generated
|
|
17
|
+
* `lib/modules/standard-sources.ts` (`deno task modules:embed`, checked by
|
|
18
|
+
* `deno task modules:check`), so the CLI, the compiled binary, the npm package,
|
|
19
|
+
* `HCLang`, and the browser playground serve the same text without reading a
|
|
20
|
+
* file at run time.
|
|
21
|
+
*
|
|
22
|
+
* @module
|
|
23
|
+
*/
|
|
24
|
+
import { ResourceMapStore, } from "../frames/resource-store.js";
|
|
25
|
+
import { STANDARD_SOURCES } from "./standard-sources.js";
|
|
26
|
+
/** Checked and copied once, so a host start or `reset()` only wraps a store. */
|
|
27
|
+
const overlayStandardModules = ResourceMapStore.overlay(STANDARD_SOURCES);
|
|
28
|
+
/**
|
|
29
|
+
* Lays the standard modules over a store as read-only entries.
|
|
30
|
+
*
|
|
31
|
+
* @param store The root's store, which keeps every other path.
|
|
32
|
+
* @returns A store that serves the standard modules and delegates the rest.
|
|
33
|
+
*/
|
|
34
|
+
export function withStandardModules(store) {
|
|
35
|
+
return overlayStandardModules(store);
|
|
36
|
+
}
|
|
@@ -0,0 +1,366 @@
|
|
|
1
|
+
// Generated by scripts/embed-modules.ts from lib/modules/*.hc. Do not edit.
|
|
2
|
+
// Regenerate with `deno task modules:embed`.
|
|
3
|
+
/**
|
|
4
|
+
* The maintained source of every `lib/modules/*.hc`, by canonical key, each
|
|
5
|
+
* joined from its lines.
|
|
6
|
+
*/
|
|
7
|
+
export const STANDARD_SOURCES = new Map([
|
|
8
|
+
[
|
|
9
|
+
"modules/figures.hc",
|
|
10
|
+
[
|
|
11
|
+
"#!/usr/bin/env hc",
|
|
12
|
+
"```",
|
|
13
|
+
"Figures (#382, #395)",
|
|
14
|
+
"",
|
|
15
|
+
"Relational Construction Theory has one generative operation: construct a Figure",
|
|
16
|
+
"out of zero or more already constructed Figures, its children. This module",
|
|
17
|
+
'ports History 005.30c, "The Figure class as idiomatic HC", in',
|
|
18
|
+
"`quilt+s3://protology#package=occurrence/history`.",
|
|
19
|
+
"",
|
|
20
|
+
"`Figure` is a constructor closure, and the object it returns is the class: each",
|
|
21
|
+
"method below is documented by the paragraph above it. A paragraph ends in `;`,",
|
|
22
|
+
"so it is a statement of the object rather than one of its elements, and it",
|
|
23
|
+
"never affects `=`. Every observer answers a Figure, never a number or a",
|
|
24
|
+
"Boolean: `A`, with no children, means no, and `B` means yes. So every answer can",
|
|
25
|
+
"be a child, a receiver, or an argument, and the class is closed under its own",
|
|
26
|
+
"methods. Only Form and Text leave the class, on purpose: they answer a plain",
|
|
27
|
+
"bracket tree and its text, for reading a Figure rather than computing with it.",
|
|
28
|
+
"",
|
|
29
|
+
"A method names its own Figure `_^`, because a bare name is looked up on the",
|
|
30
|
+
"argument first (spec 7), and the argument is usually another Figure. For the",
|
|
31
|
+
"same reason, a block inside a method reads only names the method bound",
|
|
32
|
+
"```",
|
|
33
|
+
".Figure {[",
|
|
34
|
+
"```",
|
|
35
|
+
"**Children.** `Figure [c, …]` keeps exactly the Figures in the bracket, in",
|
|
36
|
+
"order, each one itself rather than a copy, so `(x.children .0) === c`",
|
|
37
|
+
"```;",
|
|
38
|
+
" .children (_ | []);",
|
|
39
|
+
"```",
|
|
40
|
+
"**Application**, `x y` (#375): a new Figure with x's children followed by y.",
|
|
41
|
+
"It leaves x unchanged and forgets nothing, so `ys | x` joins two Figures and",
|
|
42
|
+
"`cs | (Figure [])` constructs one out of a stream",
|
|
43
|
+
"```;",
|
|
44
|
+
" .apply {Figure ((_^.children | []) _)};",
|
|
45
|
+
"```",
|
|
46
|
+
"**Manyness**, `x.many()`: a tally with one mark `B` per immediate child. It",
|
|
47
|
+
"keeps how many children there are and forgets what they are, everything below",
|
|
48
|
+
"them, their order and their identity",
|
|
49
|
+
"```;",
|
|
50
|
+
" .many {Figure (_^.children & {B})};",
|
|
51
|
+
"```",
|
|
52
|
+
"**Size**, `x.size()`: a tally with one unit cell `U` per cell. Any Figure shaped",
|
|
53
|
+
"like `U` is a cell; every other Figure adds up the Sizes of its children by",
|
|
54
|
+
"joining them into `Tally Z`. It keeps the cell count and forgets shape, nesting,",
|
|
55
|
+
"order, reuse and identity. The unit case comes first, because a unit's only",
|
|
56
|
+
"child is `Z`",
|
|
57
|
+
"```;",
|
|
58
|
+
" .size {.kids _^.children;",
|
|
59
|
+
" (kids = U.children) ? {Figure [U]} : {((kids & {_.size()}) | (Tally Z)).row}};",
|
|
60
|
+
"```",
|
|
61
|
+
"**Multiplication**, `x.mul y`: y once for every cell of x, and `Z` when y is",
|
|
62
|
+
"`Z`. It keeps y's identity in every position and forgets x's shape",
|
|
63
|
+
"```;",
|
|
64
|
+
" .mul {.y _; .cells ((_^.size()).children);",
|
|
65
|
+
" (y = Z) ? {Z} : {Figure (cells & {y})}};",
|
|
66
|
+
"```",
|
|
67
|
+
"**Tally multiplication**, `x.size_mul y`: the Size of a Figure holding y once",
|
|
68
|
+
"per child of x. It keeps the cell count and forgets both shapes",
|
|
69
|
+
"```;",
|
|
70
|
+
" .size_mul {.y _; (Figure (_^.children & {y})).size()};",
|
|
71
|
+
"```",
|
|
72
|
+
"**Size-equivalence**, `x.size_equivalent y`: `U` when the two Sizes agree and",
|
|
73
|
+
"`Z` otherwise. It keeps only whether the cell counts agree",
|
|
74
|
+
"```;",
|
|
75
|
+
" .size_equivalent {((_^.size()) = (_.size())) ? {U} : {Z}};",
|
|
76
|
+
"```",
|
|
77
|
+
"**Sameness of form**, `x.sameform y`: `B` when `x = y`. It compares child by",
|
|
78
|
+
"child and forgets identity and reuse",
|
|
79
|
+
"```;",
|
|
80
|
+
" .sameform {(_^ = _) ? {B} : {A}};",
|
|
81
|
+
"```",
|
|
82
|
+
"**Sameness**, `x.sameness y`: `B` when `x === y`, the same constructed Figure.",
|
|
83
|
+
"It keeps identity only and forgets form",
|
|
84
|
+
"```;",
|
|
85
|
+
" .sameness {(_^ === _) ? {B} : {A}};",
|
|
86
|
+
"```",
|
|
87
|
+
"**Withness**, `x.withness [f, …]`: `B` when every f is an immediate child of x,",
|
|
88
|
+
"the same Figure rather than an equal-looking one. It is relative to one parent,",
|
|
89
|
+
"the receiver, and forgets the children's order, repeats, and everything below",
|
|
90
|
+
"them. A requested Figure is absent when no child is identical to it",
|
|
91
|
+
"```;",
|
|
92
|
+
" .withness {.kids _^.children;",
|
|
93
|
+
" .absent ((_ & {.f _;",
|
|
94
|
+
" .found ((kids & {(_ === f) ? {f}}) | []);",
|
|
95
|
+
" (found = []) ? {f}}) | []);",
|
|
96
|
+
" (absent = []) ? {B} : {A}};",
|
|
97
|
+
"```",
|
|
98
|
+
"**Form**, `x.form()`: the plain bracket tree of x, one bracket per Figure, the",
|
|
99
|
+
"way 005.30c wrote Figures before they were a class. It keeps shape and order,",
|
|
100
|
+
"and forgets identity and the methods",
|
|
101
|
+
"```;",
|
|
102
|
+
" .form {_^.children & {_.form()}};",
|
|
103
|
+
"```",
|
|
104
|
+
"**Text**, `“” x`: the form spelled as text, so a Figure interpolates as",
|
|
105
|
+
"`[[], [[]]]` rather than as every method it declares (#398). Printing x still",
|
|
106
|
+
"shows its full spelling, which reads back",
|
|
107
|
+
"```;",
|
|
108
|
+
" .toText {“” (_^.form())}",
|
|
109
|
+
"]};",
|
|
110
|
+
"```",
|
|
111
|
+
"**Tally** is a helper receiver, not a Figure. Its `row` starts at `Z`, and",
|
|
112
|
+
"applying a tally to it appends that tally's units, one at a time, through",
|
|
113
|
+
"`x y`, so a reduce into `Tally Z` adds counts",
|
|
114
|
+
"```",
|
|
115
|
+
".Tally {[.row _; .apply {Tally (_.children | _^.row)}]};",
|
|
116
|
+
"```",
|
|
117
|
+
"## Construction",
|
|
118
|
+
"",
|
|
119
|
+
"The example family reuses one `A` under both `B` and `E`. Indexing reaches a",
|
|
120
|
+
"child itself, not a copy",
|
|
121
|
+
"```",
|
|
122
|
+
"; .A (Figure []); .B (Figure [A]); .C (Figure [B]); .D (Figure [C]);",
|
|
123
|
+
"; .E (Figure [A, B]); .F (Figure [B, C]); .G (Figure [E, F]);",
|
|
124
|
+
"; [(G.children .0) === E, (E.children .1) === B, (F.children .0) === B, (E.children .0) === (B.children .0)]",
|
|
125
|
+
"# [<>, <>, <>, <>]",
|
|
126
|
+
"```",
|
|
127
|
+
"Form is the bracket tree a Figure is built as, and text spells it",
|
|
128
|
+
"```",
|
|
129
|
+
"; [(E.form()) = [[], [[]]], (E.form()) = [A.form(), B.form()], ((Figure []).form()) = []]",
|
|
130
|
+
"# [<>, <>, <>]",
|
|
131
|
+
"; [(“” E) = “[[], [[]]]”, (“G is ” G) = “G is [[[], [[]]], [[[]], [[[]]]]]”]",
|
|
132
|
+
"# [<>, <>]",
|
|
133
|
+
"```",
|
|
134
|
+
"Equal children make equal Figures, but each construction is a different Figure",
|
|
135
|
+
"```",
|
|
136
|
+
"; [E = (Figure [A, B]), E == (Figure [A, B]), E === (Figure [A, B]), E = (Figure [B, A])]",
|
|
137
|
+
"# [<>, <>, (), ()]",
|
|
138
|
+
"```",
|
|
139
|
+
"Application appends one child and leaves the receiver alone, so a reduce into",
|
|
140
|
+
"an empty Figure constructs, and a map extends one Figure per element",
|
|
141
|
+
"```",
|
|
142
|
+
"; [(E B) = (Figure [A, B, B]), ((E B).children .2) === B, E = (Figure [A, B])]",
|
|
143
|
+
"# [<>, <>, <>]",
|
|
144
|
+
"; [([A, B] | (Figure [])) = E, ([A, B] | (Figure [])) === E]",
|
|
145
|
+
"# [<>, ()]",
|
|
146
|
+
"; ([A, B] & (Figure [C])) = [Figure [C, A], Figure [C, B]]",
|
|
147
|
+
"# <>",
|
|
148
|
+
"```",
|
|
149
|
+
"## Manyness and Size",
|
|
150
|
+
"",
|
|
151
|
+
"Manyness marks the immediate children and looks no deeper",
|
|
152
|
+
"```",
|
|
153
|
+
"; [(A.many()) = A, (E.many()) = (Figure [B, B]), (G.many()) = (E.many()), (E.many()) = (B.many())]",
|
|
154
|
+
"# [<>, <>, <>, ()]",
|
|
155
|
+
"```",
|
|
156
|
+
"Size is recursive cell volume. `Z` reuses `A` as the additive zero and `U`",
|
|
157
|
+
"reuses `B` as the unit cell, the same mark Manyness uses, so a count is itself a",
|
|
158
|
+
"Figure of units. Size maps each child to its Size and joins them into",
|
|
159
|
+
"`Tally Z`; the unit case comes first because a unit's only child is `Z`, and it",
|
|
160
|
+
"tests form, so any Figure shaped like `U` is a cell",
|
|
161
|
+
"```",
|
|
162
|
+
"; .Z A; .U B;",
|
|
163
|
+
"; [(Z.size()) = Z, (U.size()) = (Figure [U]), ((Figure [U]).size()) = ((Figure [Figure [A]]).size())]",
|
|
164
|
+
"# [<>, <>, <>]",
|
|
165
|
+
"; .row2 (Figure [U, U]); .row3 (Figure [U, U, U]); .row4 (Figure [U, U, U, U]);",
|
|
166
|
+
"; .deep4 (Figure [Figure [Figure [row4]]]); .two_fours (Figure [row4, row4]);",
|
|
167
|
+
"; [(row4.size()) = row4, (deep4.size()) = row4, (two_fours.size()) = (row4.children | row4)]",
|
|
168
|
+
"# [<>, <>, <>]",
|
|
169
|
+
"; [(row4.many()) = (row4.size()), (deep4.many()) = (deep4.size()), (two_fours.many()) = row2]",
|
|
170
|
+
"# [<>, (), <>]",
|
|
171
|
+
"; ((Tally Z).row) = Z",
|
|
172
|
+
"# <>",
|
|
173
|
+
"```",
|
|
174
|
+
"A tally is its own Size, so Size is idempotent",
|
|
175
|
+
"```",
|
|
176
|
+
"; ((two_fours.size()).size()) = (two_fours.size())",
|
|
177
|
+
"# <>",
|
|
178
|
+
"```",
|
|
179
|
+
"## The semiring",
|
|
180
|
+
"",
|
|
181
|
+
"The carrier is not raw Figures. Let `F` be the finite, well-founded Figures,",
|
|
182
|
+
"with the form of `U` as the unit cell, and write `x ≈ y` when",
|
|
183
|
+
"`(x.size()) = (y.size())`. The carrier is the quotient `F/≈`, with zero `Z` and",
|
|
184
|
+
"one `U`. Addition is construction, `Figure [x, y]`. Multiplication maps every",
|
|
185
|
+
"cell of `x.size()` to `y`, so a product reuses `y` once per cell of `x`. A",
|
|
186
|
+
"product by `Z` is `Z`, because one row of nothing, `Figure [Z]`, has the form of",
|
|
187
|
+
"`U` and would count as a cell",
|
|
188
|
+
"```",
|
|
189
|
+
"; [(U.mul Z) = Z, ((Figure [Z]).size()) = (Figure [U])]",
|
|
190
|
+
"# [<>, <>]",
|
|
191
|
+
"```",
|
|
192
|
+
"A non-square product is two occurrences of one three-cell row, and both",
|
|
193
|
+
"positions are the same `row3`. Manyness sees two rows, while Size counts six",
|
|
194
|
+
"```",
|
|
195
|
+
"; .rectangle23 (row2.mul row3);",
|
|
196
|
+
"; [rectangle23 = (Figure [row3, row3]), (rectangle23.children .0) === row3, (rectangle23.children .1) === row3]",
|
|
197
|
+
"# [<>, <>, <>]",
|
|
198
|
+
"; [(rectangle23.many()) = row2, (rectangle23.size()) = (Figure [U, U, U, U, U, U])]",
|
|
199
|
+
"# [<>, <>]",
|
|
200
|
+
"```",
|
|
201
|
+
"Size takes construction to joining and multiplication to `size_mul`, so both",
|
|
202
|
+
"recipes respect `≈`; the checks also use differently nested, equal-Size inputs",
|
|
203
|
+
"```",
|
|
204
|
+
"; [((Figure [row2, row3]).size()) = (Figure [U, U, U, U, U]), (rectangle23.size()) = ((row2.size()).size_mul (row3.size()))]",
|
|
205
|
+
"# [<>, <>]",
|
|
206
|
+
"; .deep2 (Figure [Figure [row2]]); .deep3 (Figure [Figure [Figure [row3]]]);",
|
|
207
|
+
"; [row2.size_equivalent deep2, row3.size_equivalent deep3, (Figure [row2, row3]).size_equivalent (Figure [deep2, deep3]), (row2.mul row3).size_equivalent (deep2.mul deep3)] = [U, U, U, U]",
|
|
208
|
+
"# <>",
|
|
209
|
+
"```",
|
|
210
|
+
"Tallies are the natural numbers in unary, so induction gives every semiring law",
|
|
211
|
+
"on tallies, and transport along Size gives them on `F/≈`. The raw product is not",
|
|
212
|
+
"commutative: `row2` by `row3` is two rows of three, `row3` by `row2` three rows",
|
|
213
|
+
"of two, and they agree only in Size. These instances witness each law without",
|
|
214
|
+
"replacing the proof",
|
|
215
|
+
"```",
|
|
216
|
+
"; [(row2.mul row3) = (row3.mul row2), ((row2.mul row3).size_equivalent (row3.mul row2)) = U]",
|
|
217
|
+
"# [(), <>]",
|
|
218
|
+
"; [(Figure [Z, row2]).size_equivalent row2, (Figure [row2, Z]).size_equivalent row2, (U.mul row2).size_equivalent row2, (row2.mul U).size_equivalent row2] = [U, U, U, U]",
|
|
219
|
+
"# <>",
|
|
220
|
+
"; [(Figure [Figure [row2, row3], row4]).size_equivalent (Figure [row2, Figure [row3, row4]]), (Figure [row2, row3]).size_equivalent (Figure [row3, row2])] = [U, U]",
|
|
221
|
+
"# <>",
|
|
222
|
+
"; (((row2.mul row3).mul row4).size_equivalent (row2.mul (row3.mul row4))) = U",
|
|
223
|
+
"# <>",
|
|
224
|
+
"; [(row2.mul (Figure [row3, row4])).size_equivalent (Figure [row2.mul row3, row2.mul row4]), ((Figure [row2, row3]).mul row4).size_equivalent (Figure [row2.mul row4, row3.mul row4])] = [U, U]",
|
|
225
|
+
"# <>",
|
|
226
|
+
"; [(Z.mul row3).size_equivalent Z, (row3.mul Z).size_equivalent Z] = [U, U]",
|
|
227
|
+
"# <>",
|
|
228
|
+
"```",
|
|
229
|
+
"## Sameness and Withness",
|
|
230
|
+
"",
|
|
231
|
+
"Sameness of form is `=` and sameness of the constructed Figure is `===`",
|
|
232
|
+
"```",
|
|
233
|
+
"; .B2 (Figure [A]);",
|
|
234
|
+
"; [B.sameform B2, B.sameness B, B.sameness B2, (E.children .0).sameness A] = [B, B, A, B]",
|
|
235
|
+
"# <>",
|
|
236
|
+
"```",
|
|
237
|
+
"Withness asks whether every requested Figure is an immediate child of the",
|
|
238
|
+
"receiver, by identity rather than form: `B` is reused under both `E` and `F`,",
|
|
239
|
+
"while the separately constructed `B2` is a child of neither. An empty parent",
|
|
240
|
+
"holds nothing, and every one of no Figures is a child of any parent",
|
|
241
|
+
"```",
|
|
242
|
+
"; [E.withness [A, B], F.withness [A, B], G.withness [E, F], E.withness [B2]] = [B, A, B, A]",
|
|
243
|
+
"# <>",
|
|
244
|
+
"; [A.withness [B], B.withness []] = [A, B]",
|
|
245
|
+
"# <>",
|
|
246
|
+
"```",
|
|
247
|
+
"## The Fano plane",
|
|
248
|
+
"",
|
|
249
|
+
"Seven originals of identical form, each a fresh `Figure []`, and seven triples",
|
|
250
|
+
"of identical form `[[], [], []]`. The incidence lives only in which originals",
|
|
251
|
+
"each triple reuses, so only Withness, by identity, can see it. `b_copy` equals",
|
|
252
|
+
"every original in form and is a child of no triple",
|
|
253
|
+
"```",
|
|
254
|
+
"; .a (Figure []); .b (Figure []); .c (Figure []); .d (Figure []); .e (Figure []); .f (Figure []); .g (Figure []);",
|
|
255
|
+
"; .originals (Figure [a, b, c, d, e, f, g]);",
|
|
256
|
+
"; .abd (Figure [a, b, d]); .bce (Figure [b, c, e]); .cdf (Figure [c, d, f]);",
|
|
257
|
+
"; .deg (Figure [d, e, g]); .efa (Figure [e, f, a]); .fgb (Figure [f, g, b]); .gac (Figure [g, a, c]);",
|
|
258
|
+
"; .fano (Figure [abd, bce, cdf, deg, efa, fgb, gac]);",
|
|
259
|
+
"; .Three (Figure [U, U, U]); .b_copy (Figure []);",
|
|
260
|
+
"; [(originals.many()) = (fano.many()), (fano.children & {_.many()}) = (fano.children & {Three})]",
|
|
261
|
+
"# [<>, <>]",
|
|
262
|
+
"; [abd = bce, abd === bce, b = b_copy, b === b_copy]",
|
|
263
|
+
"# [<>, (), <>, ()]",
|
|
264
|
+
"; [abd.withness [a, b, d], abd.withness [a, c], abd.withness [b_copy]] = [B, A, A]",
|
|
265
|
+
"# <>",
|
|
266
|
+
"```",
|
|
267
|
+
"`on` answers one Withness mark per triple, so its Size counts the triples that",
|
|
268
|
+
"hold every requested original. Over every ordered pair, generated rather than",
|
|
269
|
+
"listed, two distinct originals lie in exactly one triple and each lies in three",
|
|
270
|
+
"```",
|
|
271
|
+
"; .on {.points _; Figure (fano.children & {_.withness points})};",
|
|
272
|
+
"; .point_table (originals.children & {.p _; originals.children & {(on [p, _]).size()}});",
|
|
273
|
+
"; point_table = (originals.children & {.p _; originals.children & {(p === _) ? {Three} : {Figure [U]}}})",
|
|
274
|
+
"# <>",
|
|
275
|
+
"```",
|
|
276
|
+
"Dually, `meet` counts the originals two triples share: multiplying their two",
|
|
277
|
+
"Withness marks leaves one cell exactly when both hold it. The two tables are",
|
|
278
|
+
"equal, which is the plane's self-duality",
|
|
279
|
+
"```",
|
|
280
|
+
"; .meet {.lines _; (Figure (originals.children & {.o _; ((lines .0).withness [o]).mul ((lines .1).withness [o])})).size()};",
|
|
281
|
+
"; .line_table (fano.children & {.l _; fano.children & {meet [l, _]}});",
|
|
282
|
+
"; [line_table = (fano.children & {.l _; fano.children & {(l === _) ? {Three} : {Figure [U]}}}), point_table = line_table]",
|
|
283
|
+
"# [<>, <>]",
|
|
284
|
+
"```",
|
|
285
|
+
"`a, b, c, f` are four originals with no three in a triple",
|
|
286
|
+
"```",
|
|
287
|
+
"; ([[a, b, c], [a, b, f], [a, c, f], [b, c, f]] & {(on _).size()}) = [Z, Z, Z, Z]",
|
|
288
|
+
"# <>",
|
|
289
|
+
"```",
|
|
290
|
+
"## Closure",
|
|
291
|
+
"",
|
|
292
|
+
"Every answer is a Figure, so it can be observed again or become a child, and",
|
|
293
|
+
"observing does not mutate, even with a local name inside a map",
|
|
294
|
+
"```",
|
|
295
|
+
"; [((E.many()).many()) = (E.many()), ((Figure [E.many(), F.size()]).size()) = row4]",
|
|
296
|
+
"# [<>, <>]",
|
|
297
|
+
"; .E5 (Figure [A, Figure [A]]);",
|
|
298
|
+
"; E5.children & {.o _; o};",
|
|
299
|
+
"; [E5 = (Figure [A, B]), A = (Figure [])]",
|
|
300
|
+
"# [<>, <>]",
|
|
301
|
+
"```",
|
|
302
|
+
"## Names",
|
|
303
|
+
"",
|
|
304
|
+
"A bare name inside a block that a map applies to Figures reads each Figure's",
|
|
305
|
+
"own members first (spec 7), so it cannot reach the method's. That is why a",
|
|
306
|
+
"method names its own Figure `_^` and binds `kids` before its blocks read it",
|
|
307
|
+
"```",
|
|
308
|
+
"; (E.children & {children}) = [A.children, B.children]",
|
|
309
|
+
"# <>",
|
|
310
|
+
"```",
|
|
311
|
+
"A method's own locals come ahead of any binding where it is called, and a",
|
|
312
|
+
"Figure passed as an argument contributes only its members, never the names of",
|
|
313
|
+
"the scope that built it. The Fano plane above already binds `f`, the name",
|
|
314
|
+
"Withness uses inside its blocks; these bind the other locals",
|
|
315
|
+
"```",
|
|
316
|
+
"; .kids 9; .y 9; .cells 9; .found 9; .absent 9;",
|
|
317
|
+
"; [(E.withness [A, B]) = B, (row2.mul row3) = rectangle23, (E.size()) = (Figure [U])]",
|
|
318
|
+
"# [<>, <>, <>]",
|
|
319
|
+
"```",
|
|
320
|
+
"A method's free names resolve where the method was written, never where its",
|
|
321
|
+
"receiver was read (#400). So a scope that binds its own `B` and reads a Figure",
|
|
322
|
+
"by name there still gets the class's `B` back from Manyness",
|
|
323
|
+
"```",
|
|
324
|
+
"; .theB B;",
|
|
325
|
+
"; .rebinds {.B 5; .mine (Figure [A]); ((mine.many()).children .0) === theB};",
|
|
326
|
+
"; rebinds()",
|
|
327
|
+
"# <>",
|
|
328
|
+
"```",
|
|
329
|
+
"## Functional updates",
|
|
330
|
+
"",
|
|
331
|
+
"A mutating method reached through an immutable handle is a functional update,",
|
|
332
|
+
"and it copies only what it writes (#401). A Figure the receiver holds is never",
|
|
333
|
+
"written, so the result holds the very same Figure, and identity observers",
|
|
334
|
+
"answer about it",
|
|
335
|
+
"```",
|
|
336
|
+
"; .keeper [.fig E; .touch_ {@fig fig;}];",
|
|
337
|
+
"; .kept ((keeper.touch_ ()).fig);",
|
|
338
|
+
"; [kept === E, (kept.children .0) === A]",
|
|
339
|
+
"# [<>, <>]",
|
|
340
|
+
"; [kept.sameness kept, kept.withness [kept.children .0]] = [B, B]",
|
|
341
|
+
"# <>",
|
|
342
|
+
"```",
|
|
343
|
+
"A write that constructs answers a new Figure, which is a Figure like any other",
|
|
344
|
+
"```",
|
|
345
|
+
"; .grower [.fig E; .grow_ {@fig (fig B);}];",
|
|
346
|
+
"; .grown ((grower.grow_ ()).fig);",
|
|
347
|
+
"; [(grown.sameness grown) = B, (grown.withness [grown.children .2]) = B, grown === E]",
|
|
348
|
+
"# [<>, <>, ()]",
|
|
349
|
+
"```",
|
|
350
|
+
"## Spelling",
|
|
351
|
+
"",
|
|
352
|
+
"`(x)` is `x`, so `Figure (B)` collects B's elements, of which an object with",
|
|
353
|
+
"only properties has none. Write `Figure [B]`",
|
|
354
|
+
"```",
|
|
355
|
+
"; [(Figure (B)) = A, (Figure [B]) = C]",
|
|
356
|
+
"# [<>, <>]",
|
|
357
|
+
"```",
|
|
358
|
+
"Importing this file answers its last form, which the hosts' smoke tests read,",
|
|
359
|
+
"so the file ends on a claim that holds however the rest of it changes",
|
|
360
|
+
"```",
|
|
361
|
+
"; (Figure [A, B]) = E",
|
|
362
|
+
"# <>",
|
|
363
|
+
"",
|
|
364
|
+
].join("\n"),
|
|
365
|
+
],
|
|
366
|
+
]);
|
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.20.
|
|
1
|
+
export const VERSION = "0.20.2";
|