hclang 0.17.0 → 0.17.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.
@@ -135,6 +135,16 @@ export class FrameArray extends FrameList {
135
135
  collects() {
136
136
  return true;
137
137
  }
138
+ /**
139
+ * A fresh aggregate holding the same elements. Only the outer aggregate is
140
+ * new: the elements are shared, so collecting reuses them rather than
141
+ * copying, and `===` still finds each one.
142
+ */
143
+ collectingCopy() {
144
+ const result = this.copy();
145
+ result.data = [...this.data];
146
+ return result;
147
+ }
138
148
  apply(argument, _parameter) {
139
149
  if (!argument.is.void) {
140
150
  this.data.push(argument);
@@ -7,10 +7,11 @@ import { methodEffect } from "./effect-marker.js";
7
7
  *
8
8
  * The handle's charter is that reference and nothing more. Two rules define it:
9
9
  *
10
- * - **Transparency.** Wrapping must not change what a value prints, equals, or
11
- * exposes, so rendering, data, metadata, and array views all delegate to the
12
- * target. A handle is invisible to comparison, and assignment unwraps it, so
13
- * a mutation lands on the same frame it would have without the wrapper.
10
+ * - **Transparency.** Wrapping must not change what a value prints, equals,
11
+ * exposes, or answers when applied, so rendering, data, metadata, array
12
+ * views, and application all delegate to the target. A handle is invisible to
13
+ * comparison, and assignment unwraps it, so a mutation lands on the same
14
+ * frame it would have without the wrapper.
14
15
  * - **Caller-scoped lookup.** A handle created by symbol lookup carries that
15
16
  * read's lexical context separately from the shared target. Local and
16
17
  * declared-parent lookup remains live on the target, then falls back through
@@ -125,6 +126,19 @@ export class FrameHandle extends Frame {
125
126
  called_by(context, parameter) {
126
127
  return context.apply(this.target, parameter);
127
128
  }
129
+ /** Transparency covers application: a named aggregate collects like its literal. */
130
+ collects() {
131
+ return this.target.collects();
132
+ }
133
+ /**
134
+ * Applying through a name answers what applying the value would, without
135
+ * writing through the name. A collect lands on a fresh aggregate, so `xs 3`
136
+ * answers a new array and `xs` is unchanged, whether or not the name is
137
+ * mutable: a write goes through a mutating method or `@`, never application.
138
+ */
139
+ apply(argument, parameter) {
140
+ return this.target.collectingCopy().apply(argument, parameter);
141
+ }
128
142
  toString() {
129
143
  return this.target.toString();
130
144
  }
@@ -302,6 +302,17 @@ export class Frame extends MetaFrame {
302
302
  collects() {
303
303
  return false;
304
304
  }
305
+ /**
306
+ * The receiver a collect lands on when it must not write this frame.
307
+ *
308
+ * A literal is a fresh aggregate each time it is evaluated, so collecting
309
+ * into it in place is unobservable. A value reached through a name is not,
310
+ * so the name asks for this instead. Anything that does not collect is its
311
+ * own receiver.
312
+ */
313
+ collectingCopy() {
314
+ return this;
315
+ }
305
316
  /**
306
317
  * The values this frame streams when it is iterated.
307
318
  *
@@ -1 +1 @@
1
- export const VERSION = "0.17.0";
1
+ export const VERSION = "0.17.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hclang",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Homoiconic C command-line interpreter and REPL",
5
5
  "keywords": [
6
6
  "language",