hclang 0.20.2 → 0.20.3

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.
@@ -31,6 +31,78 @@ class ImportProgress extends Frame {
31
31
  return value;
32
32
  }
33
33
  }
34
+ /** The prefix of a testdoc example line, `HCEval.SOURCE`. */
35
+ const EXAMPLE = "; ";
36
+ /**
37
+ * Drops a testdoc's example lines from imported source, so importing a file
38
+ * runs its code and not its examples.
39
+ *
40
+ * A line is an example when it begins with `; ` outside prose, the same test
41
+ * `HCEval.checkInput` applies when the file runs as a testdoc. Every example is
42
+ * one line, and its expectation line (`# …`) is already a comment, so dropping
43
+ * the line up to its newline leaves the rest of the source as written.
44
+ */
45
+ class ExampleFilter {
46
+ constructor() {
47
+ Object.defineProperty(this, "head", {
48
+ enumerable: true,
49
+ configurable: true,
50
+ writable: true,
51
+ value: ""
52
+ });
53
+ Object.defineProperty(this, "atLineStart", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: true
58
+ });
59
+ Object.defineProperty(this, "skipping", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: false
64
+ });
65
+ }
66
+ /**
67
+ * Answers the characters to scan for one character of source.
68
+ *
69
+ * @param character The next character of the source.
70
+ * @param prose Whether the lexer is inside a document, where `; ` is text.
71
+ * @returns The characters to scan now, possibly none.
72
+ */
73
+ filter(character, prose) {
74
+ if (this.skipping) {
75
+ if (character !== "\n")
76
+ return [];
77
+ this.skipping = false;
78
+ this.atLineStart = true;
79
+ return [character];
80
+ }
81
+ if (!this.atLineStart || prose) {
82
+ this.atLineStart = character === "\n";
83
+ return [character];
84
+ }
85
+ this.head += character;
86
+ if (this.head === EXAMPLE) {
87
+ this.head = "";
88
+ this.atLineStart = false;
89
+ this.skipping = true;
90
+ return [];
91
+ }
92
+ if (EXAMPLE.startsWith(this.head))
93
+ return [];
94
+ const kept = this.head.split("");
95
+ this.head = "";
96
+ this.atLineStart = character === "\n";
97
+ return kept;
98
+ }
99
+ /** Answers any characters still held when the source ends. */
100
+ flush() {
101
+ const kept = this.head.split("");
102
+ this.head = "";
103
+ return kept;
104
+ }
105
+ }
34
106
  const sourceTypeFailure = (value) => Frame.error(`$!.resource-import-source-type ${value.toString()}`);
35
107
  /** Evaluate a resource's character elements through the existing HC pipeline. */
36
108
  export function evaluateResourceSource(resource, scope) {
@@ -53,6 +125,13 @@ function evaluateResourceSourceWithChain(resource, scope, activeImports) {
53
125
  strictStructure: true,
54
126
  });
55
127
  let receiver = lexer;
128
+ const scan = (character) => {
129
+ receiver = sigilizer.scan(receiver, FrameSymbol.for(character));
130
+ if (receiver.isFailedResult())
131
+ return receiver;
132
+ return progress.firstFailure;
133
+ };
134
+ const examples = new ExampleFilter();
56
135
  const elements = resource.elements();
57
136
  for (const element of elements) {
58
137
  if (element.isFailedResult())
@@ -60,13 +139,19 @@ function evaluateResourceSourceWithChain(resource, scope, activeImports) {
60
139
  if (!hasCharacterContent(element))
61
140
  return sourceTypeFailure(element);
62
141
  for (const character of element.characterContent().split("")) {
63
- receiver = sigilizer.scan(receiver, FrameSymbol.for(character));
64
- if (receiver.isFailedResult())
65
- return receiver;
66
- if (progress.firstFailure)
67
- return progress.firstFailure;
142
+ const prose = receiver.is.document === true;
143
+ for (const kept of examples.filter(character, prose)) {
144
+ const failure = scan(kept);
145
+ if (failure)
146
+ return failure;
147
+ }
68
148
  }
69
149
  }
150
+ for (const kept of examples.flush()) {
151
+ const failure = scan(kept);
152
+ if (failure)
153
+ return failure;
154
+ }
70
155
  if (receiver !== lexer) {
71
156
  receiver = sigilizer.finish(receiver, FrameSymbol.end());
72
157
  if (receiver.isFailedResult())
@@ -1 +1 @@
1
- export const VERSION = "0.20.2";
1
+ export const VERSION = "0.20.3";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hclang",
3
- "version": "0.20.2",
3
+ "version": "0.20.3",
4
4
  "description": "Homoiconic C command-line interpreter and REPL",
5
5
  "keywords": [
6
6
  "language",
@@ -1,36 +0,0 @@
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
- }
@@ -1,366 +0,0 @@
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
- ]);