hclang 0.26.0 → 0.26.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.
@@ -1176,7 +1176,9 @@ export const HC_SOURCES = new Map([
1176
1176
  "",
1177
1177
  "Three observers share one form: a stream, a mark for each thing in it, and one",
1178
1178
  "construction. Manyness marks each child, Size marks each cell, and",
1179
- "Multiplication puts y at each cell. No observer counts. A number appears only",
1179
+ "Multiplication puts y at each cell. They are fewer than three constructions:",
1180
+ "Size is Multiplication by the unit, and Tally multiplication is Multiplication",
1181
+ "of a Manyness, so Multiplication holds the only zero guard. No observer counts. A number appears only",
1180
1182
  "when a tally is read as one: its children are an aggregate, so",
1181
1183
  "`(x.size()).children.#` is the FrameCount it spells, as `(x.cells()).#` is, and",
1182
1184
  "`x.children.#` counts x's children. A Figure's own `.#` and `.##` are `0`,",
@@ -1217,10 +1219,11 @@ export const HC_SOURCES = new Map([
1217
1219
  " .many {Figure (_^.children & {B})};",
1218
1220
  "```",
1219
1221
  "**Size**, `x.size()`: a tally with one unit cell `U` per cell, as Manyness has",
1220
- "one mark per child. It keeps the cell count and forgets shape, nesting, order,",
1221
- "reuse and identity",
1222
+ "one mark per child. That is Multiplication by `U`, which puts a `U` at every",
1223
+ "cell. It keeps the cell count and forgets shape, nesting, order, reuse and",
1224
+ "identity",
1222
1225
  "```;",
1223
- " .size {Figure (_^.cells() & {U})};",
1226
+ " .size {_^.mul U};",
1224
1227
  "```",
1225
1228
  "**Cells**, `x.cells()`: the cells of x, in order, each one itself. Any Figure",
1226
1229
  "shaped like `U` is a cell, and every other Figure's cells are its children's,",
@@ -1239,11 +1242,12 @@ export const HC_SOURCES = new Map([
1239
1242
  " .mul {.y _; .cells _^.cells(); (y = Z) ? {Z} : {Figure (cells & {y})}};",
1240
1243
  "```",
1241
1244
  "**Tally multiplication**, `x.size_mul y`: the Size of a Figure holding y once",
1242
- "per child of x, and `Z` when y is `Z`, for the reason Multiplication guards. It",
1243
- "keeps the cell count and forgets both shapes",
1245
+ "per child of x, and `Z` when y is `Z`. Manyness marks each child with `B`,",
1246
+ "which is `U`, so it is a tally of the children, and multiplying it by y holds y",
1247
+ "once per child. Multiplication's guard answers `Z` for a zero factor, so this",
1248
+ "needs no guard of its own. It keeps the cell count and forgets both shapes",
1244
1249
  "```;",
1245
- " .size_mul {.y _; .kids _^.children;",
1246
- " (y = Z) ? {Z} : {(Figure (kids & {y})).size()}};",
1250
+ " .size_mul {((_^.many()).mul _).size()};",
1247
1251
  "```",
1248
1252
  "**Size-equivalence**, `x.size_equivalent y`: `U` when the two Sizes are the",
1249
1253
  "same tally and `Z` otherwise. It keeps only whether the cell counts agree",
@@ -1266,9 +1270,7 @@ export const HC_SOURCES = new Map([
1266
1270
  "them. A requested Figure is absent when no child is identical to it",
1267
1271
  "```;",
1268
1272
  " .withness {.kids _^.children;",
1269
- " .absent ((_ & {.f _;",
1270
- " .found ((kids & {(_ === f) ? {f}}) | []);",
1271
- " (found = []) ? {f}}) | []);",
1273
+ " .absent (_ &| {.f _; ((kids &| {(_ === f) ? {[f]}}) = []) ? {[f]}});",
1272
1274
  " (absent = []) ? {B} : {A}};",
1273
1275
  "```",
1274
1276
  "**Form**, `x.form()`: the plain bracket tree of x, one bracket per Figure, the",
@@ -1378,8 +1380,8 @@ export const HC_SOURCES = new Map([
1378
1380
  "Tallies add without a helper: the Size of a Figure holding two tallies joins",
1379
1381
  "them, and two `Z`s add to `Z`. Add two at a time, because two children are",
1380
1382
  "never shaped like `U`. One child can be: `Figure [Z]` has the form of `U`, so",
1381
- "its Size is one cell, the rule that makes Multiplication and Tally",
1382
- "multiplication guard `Z`",
1383
+ "its Size is one cell, the rule that makes Multiplication guard `Z`, for",
1384
+ "itself and for Tally multiplication",
1383
1385
  "```",
1384
1386
  "; [((Figure [row2, row3]).size()) = (row3.children | row2), ((Figure [Z, Z]).size()) = Z, ((Figure [Z]).size()) = (Figure [U])]",
1385
1387
  "# [<>, <>, <>]",
@@ -1463,6 +1465,14 @@ export const HC_SOURCES = new Map([
1463
1465
  "; [((Figure [row2, row3]).size()) = (Figure [U, U, U, U, U]), (rectangle23.size()) = ((row2.size()).size_mul (row3.size()))]",
1464
1466
  "# [<>, <>]",
1465
1467
  "```",
1468
+ "Size is Multiplication by the unit, and Tally multiplication is Multiplication",
1469
+ "of a Manyness, whatever the nesting",
1470
+ "```",
1471
+ "; [(row2.size()) = (row2.mul U), (deep4.size()) = (deep4.mul U), (Z.size()) = (Z.mul U)]",
1472
+ "# [<>, <>, <>]",
1473
+ "; [(row2.size_mul row3) = (((row2.many()).mul row3).size()), (deep4.size_mul row3) = (((deep4.many()).mul row3).size())]",
1474
+ "# [<>, <>]",
1475
+ "```",
1466
1476
  "At a zero factor both recipes answer `Z`, a one-cell factor included",
1467
1477
  "```",
1468
1478
  "; [(U.size_mul Z) = Z, ((Figure [U]).size_mul Z) = Z, ((U.mul Z).size()) = ((U.size()).size_mul (Z.size()))]",
@@ -1577,6 +1587,15 @@ export const HC_SOURCES = new Map([
1577
1587
  "; [E5 = (Figure [A, B]), A = (Figure [])]",
1578
1588
  "# [<>, <>]",
1579
1589
  "```",
1590
+ "## Reading the methods",
1591
+ "",
1592
+ "A method read through a Figure walks as the atoms of its body, unevaluated",
1593
+ "(#429), so the module can read what an observer is built from. Size is",
1594
+ "Multiplication by the unit, and its body says so",
1595
+ "```",
1596
+ "; (E.size) & {“” _}",
1597
+ "# [“_^”, “.mul”, “U”]",
1598
+ "```",
1580
1599
  "## Names",
1581
1600
  "",
1582
1601
  "A bare name inside a block that a map applies to Figures reads each Figure's",
@@ -82,6 +82,14 @@ export class BoundMethod extends Frame {
82
82
  value: lexicalContext
83
83
  });
84
84
  }
85
+ /**
86
+ * A method walks as its closure does, the atoms of its body (#429), so a
87
+ * method read through its receiver, `e.cells`, can be inspected without
88
+ * being called. The receiver is not an atom, and the walk never reaches it.
89
+ */
90
+ elements() {
91
+ return this.method.elements();
92
+ }
85
93
  /** Whether this method was declared to mutate the frame it runs against. */
86
94
  isMutating() {
87
95
  return this.effect.mutating;
@@ -2,6 +2,7 @@
2
2
  import { Frame } from "../frames/frame.js";
3
3
  import { FrameArray } from "../frames/frame-array.js";
4
4
  import { FrameSymbol } from "../frames/frame-symbol.js";
5
+ import { BoundMethod } from "../frames/bound-method.js";
5
6
  import { FrameLazy } from "../frames/frame-lazy.js";
6
7
  import { FrameList } from "../frames/frame-list.js";
7
8
  import { FrameWord } from "../frames/frame-word.js";
@@ -68,7 +69,7 @@ export const SpliceElements = (source, receiver, receiverState) => new FrameArra
68
69
  */
69
70
  export const ReduceElements = (source, receiver, receiverState) => {
70
71
  const code = source.referent();
71
- if (code instanceof FrameLazy) {
72
+ if (code instanceof FrameLazy || code instanceof BoundMethod) {
72
73
  return code.call(receiver, Frame.nil, receiverState);
73
74
  }
74
75
  // Only an aggregate is inspected: a stream's elements are produced by
@@ -1 +1 @@
1
- export const VERSION = "0.26.0";
1
+ export const VERSION = "0.26.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hclang",
3
- "version": "0.26.0",
3
+ "version": "0.26.1",
4
4
  "description": "Homoiconic C command-line interpreter and REPL",
5
5
  "keywords": [
6
6
  "language",