hclang 0.49.0 → 0.50.0

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.
@@ -74,14 +74,13 @@ export function denumClass() {
74
74
  }
75
75
  /**
76
76
  * Constructs a Denum of any arity with the HC class: `Denum [count, loads]`.
77
- * Two loads give the binary Denum, the same instance `Denum [count, left,
78
- * right]` builds; any other nonzero number gives the channel Denum (007.27).
77
+ * Every number of loads, one or more, is the same class (007.27, 007.40).
79
78
  *
80
79
  * @param count The full application Count.
81
80
  * @param loads The ordered channel loads.
82
81
  * @returns The new instance, or the class's failure.
83
82
  */
84
- export function constructDenumLoads(count, loads) {
83
+ export function constructDenum(count, loads) {
85
84
  const constructor = denumClass();
86
85
  if (constructor.isFailedResult() || constructor.observationError()) {
87
86
  return constructor;
@@ -89,15 +88,4 @@ export function constructDenumLoads(count, loads) {
89
88
  const state = new FrameArray([count, new FrameArray([...loads])]);
90
89
  return FrameExpr.answeredValue(constructor.call(state)).referent();
91
90
  }
92
- /**
93
- * Constructs a binary Denum with the HC class: `Denum [count, left, right]`.
94
- *
95
- * @param count The full application Count; the Denum derives its phase from it.
96
- * @param left The left load.
97
- * @param right The right load.
98
- * @returns The new instance, or the class's failure.
99
- */
100
- export function constructDenum(count, left, right) {
101
- return constructDenumLoads(count, [left, right]);
102
- }
103
- installDenumConstructor(constructDenumLoads);
91
+ installDenumConstructor(constructDenum);
@@ -25,14 +25,13 @@ export const ROUTER_SOURCE = "hc/rotor-router.hc";
25
25
  /** The name the file declares the constructor under. */
26
26
  export const ROUTER_CLASS = "RotorRouter";
27
27
  /**
28
- * The builders the class file declares beside its constructor, which make an
29
- * instance from channels already known to be admissible, without validating
30
- * or copying them: `binary-router` for two channels, `channel-router` for any
31
- * other number.
28
+ * The builder the class file declares beside its constructor, which makes an
29
+ * instance of any number of channels from channels already known to be
30
+ * admissible, without validating or copying them.
32
31
  */
33
- export const ROUTER_BUILDERS = ["binary-router", "channel-router"];
32
+ export const ROUTER_BUILDER = "router-instance";
34
33
  let loaded;
35
- let builders;
34
+ let builder;
36
35
  let loading = false;
37
36
  /**
38
37
  * Evaluates class source in a namespace of its own, answering its
@@ -53,11 +52,11 @@ export function loadRouterClass(source) {
53
52
  if (constructor.is.missing) {
54
53
  return Frame.error(`$!.router-prologue-missing ${ROUTER_CLASS}`);
55
54
  }
56
- const [binary, channel] = ROUTER_BUILDERS.map((key) => namespace.getOwn(key));
57
- if (binary.is.missing || channel.is.missing) {
58
- return Frame.error(`$!.router-prologue-missing ${ROUTER_BUILDERS}`);
55
+ const instance = namespace.getOwn(ROUTER_BUILDER);
56
+ if (instance.is.missing) {
57
+ return Frame.error(`$!.router-prologue-missing ${ROUTER_BUILDER}`);
59
58
  }
60
- builders = { binary, channel };
59
+ builder = instance;
61
60
  return constructor;
62
61
  }
63
62
  /**
@@ -94,8 +93,8 @@ export function constructRouter(channels) {
94
93
  return FrameExpr.answeredValue(constructor.call(channels)).referent();
95
94
  }
96
95
  /**
97
- * The channels of an instance of the shipped class with other than two
98
- * channels, for `.####` (007.27); undefined for anything else.
96
+ * The channels of an instance of the shipped class, for `.####` (007.27);
97
+ * undefined for anything else.
99
98
  *
100
99
  * Recognition mirrors the Denum's (007.25e): the source's own stored
101
100
  * `channels`, a list of arrays, must rebuild through the constructor into a
@@ -113,7 +112,7 @@ export function channelRouterChannels(source) {
113
112
  if (!(stored instanceof FrameArray))
114
113
  return undefined;
115
114
  const channels = stored.elements().map((channel) => channel.referent());
116
- if (channels.length === 0 || channels.length === 2)
115
+ if (channels.length === 0)
117
116
  return undefined;
118
117
  if (!channels.every((channel) => channel instanceof FrameArray)) {
119
118
  return undefined;
@@ -142,12 +141,9 @@ export function dealtRouter(channels) {
142
141
  if (constructor.isFailedResult() || constructor.observationError()) {
143
142
  return constructor;
144
143
  }
145
- if (!builders)
144
+ if (!builder)
146
145
  return Frame.error("$!.router-unavailable /");
147
- const build = channels.elements().length === 2
148
- ? builders.binary
149
- : builders.channel;
150
- return FrameExpr.answeredValue(build.call(channels)).referent();
146
+ return FrameExpr.answeredValue(builder.call(channels)).referent();
151
147
  }
152
148
  installDivisionCarrier(dealtRouter);
153
149
  installRouterRecognizer(channelRouterChannels);
@@ -50,7 +50,7 @@ function storedLoads(source) {
50
50
  }
51
51
  /**
52
52
  * The intrinsic Denum path (007.25e). A constructed Denum is the one Frame whose
53
- * fourth hash the three observers cannot decide: `Denum [0, 0, 0]` reads 0, 0,
53
+ * fourth hash the three observers cannot decide: `Denum [0, [0, 0]]` reads 0, 0,
54
54
  * 0, exactly as `[]` does, yet it is a present state. Rather than let any
55
55
  * class declare its own `.####`, the fourth hash recognizes an instance of the
56
56
  * shipped class itself, and nothing else.
@@ -148,17 +148,14 @@ export function bindDenumCount(source) {
148
148
  return construct(new FrameCount(state.count), bound.map((load) => new FrameCount(load)));
149
149
  }
150
150
  /**
151
- * The channel-router path (007.27). A router of k channels routes to channel
152
- * C mod k, which only a Denum of k loads follows; the binary Denum the observers
153
- * derive follows parity, so for k other than two it would not be the router's
154
- * shadow. An instance of the shipped `RotorRouter` class with other than two
155
- * channels therefore answers the channel Denum of its Count and channel loads,
156
- * `Denum [C, [load0, …]]`, where a load is the summed Size of a channel's
157
- * children and an empty channel's load is 0. The binary router keeps the
158
- * derived path, which already answers `Denum(C, L, R)`.
151
+ * The router path (007.27). A router of k channels routes to channel C mod k,
152
+ * which only a Denum of k loads follows, so an instance of the shipped
153
+ * `RotorRouter` class, of any number of channels, answers the Denum of its
154
+ * Count and channel loads, `Denum [C, [load0, …]]`, where a load is the summed
155
+ * Size of a channel's children and an empty channel's load is 0.
159
156
  *
160
157
  * Its Count is the children it holds; at Count zero it has no Denum, as the
161
- * empty binary router and the empty host have none. Each child's Size is read
158
+ * empty host has none. Each child's Size is read
162
159
  * once, and a failed Size is answered as it is.
163
160
  *
164
161
  * @param source The observed Frame.
@@ -199,7 +196,7 @@ function channelRouterDenum(source) {
199
196
  * caches the source, and reads each observer at most once.
200
197
  *
201
198
  * A derived source with Count zero is nil: a host with no children has no
202
- * Denum, so `[].####` and `0.####` are nil while `(Denum [0, 0, 0]).####` is
199
+ * Denum, so `[].####` and `0.####` are nil while `(Denum [0, [0, 0]]).####` is
203
200
  * present. No class can declare `.####` for itself; only the three observers
204
201
  * are declarable (`FrameArray.OBSERVATION_KEYS`).
205
202
  *
@@ -1 +1 @@
1
- export const VERSION = "0.49.0";
1
+ export const VERSION = "0.50.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hclang",
3
- "version": "0.49.0",
3
+ "version": "0.50.0",
4
4
  "description": "Homoiconic C command-line interpreter and REPL",
5
5
  "keywords": [
6
6
  "language",