hclang 0.24.1 → 0.24.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.
|
@@ -3383,6 +3383,13 @@ export const HC_SOURCES = new Map([
|
|
|
3383
3383
|
"; mag (.x 1; .y 2;)",
|
|
3384
3384
|
"# 5",
|
|
3385
3385
|
"```",
|
|
3386
|
+
"Each call evaluates the body afresh, so a group the body builds holds that",
|
|
3387
|
+
"call's values, as an array does (#404):",
|
|
3388
|
+
"```",
|
|
3389
|
+
"; .pair {(.a _; .b (a + 1);)};",
|
|
3390
|
+
"; [pair 1, pair 2]",
|
|
3391
|
+
"# [(.a 1; .b 2;), (.a 2; .b 3;)]",
|
|
3392
|
+
"```",
|
|
3386
3393
|
"You can reach past the argument to the enclosing lexical scope (one level above)",
|
|
3387
3394
|
"using the `_^` identifier. It is not a `super` reference: it names the scope the",
|
|
3388
3395
|
"closure was written in, not a declared parent, and each caret is one more",
|
|
@@ -9,20 +9,36 @@ export class FrameGroup extends FrameList {
|
|
|
9
9
|
constructor(data, meta = NilContext) {
|
|
10
10
|
super(data, meta);
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
/**
|
|
13
|
+
* The scope this group's terms are evaluated in. `target` is the layer they
|
|
14
|
+
* read the group's properties from and, for a group written in source, the
|
|
15
|
+
* frame their declarations land on.
|
|
16
|
+
*/
|
|
17
|
+
scoped(input, target) {
|
|
18
|
+
const scope = EvaluationScope.from(input).withLayer(target);
|
|
19
|
+
return this.declares
|
|
20
|
+
? scope.withWriteTarget(target, "construction")
|
|
21
|
+
: scope;
|
|
15
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* A group of one answers its term, carrying the group's properties. They
|
|
25
|
+
* are collected on a fresh copy, so one evaluation's declarations reach its
|
|
26
|
+
* own answer and never a later evaluation of the same group (#404).
|
|
27
|
+
*/
|
|
16
28
|
eval_one(input = []) {
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const symbols = this.meta_pairs();
|
|
21
|
-
symbols.forEach(([key, value]) => {
|
|
29
|
+
const target = this.copy();
|
|
30
|
+
const result = this.data[0].in(this.scoped(input, target));
|
|
31
|
+
target.meta_pairs().forEach(([key, value]) => {
|
|
22
32
|
result.set(key, value);
|
|
23
33
|
});
|
|
24
34
|
return result;
|
|
25
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* A parsed group is source, and a closure evaluates the same one on every
|
|
38
|
+
* call, so the value is always a fresh group and this one is never written.
|
|
39
|
+
* Evaluating in place replaced its terms with the first call's answers,
|
|
40
|
+
* which every later call then answered again (#404).
|
|
41
|
+
*/
|
|
26
42
|
in(input = []) {
|
|
27
43
|
switch (this.size()) {
|
|
28
44
|
case 0: {
|
|
@@ -32,9 +48,10 @@ export class FrameGroup extends FrameList {
|
|
|
32
48
|
return this.eval_one(input);
|
|
33
49
|
}
|
|
34
50
|
}
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
const result = this.copy();
|
|
52
|
+
const scope = this.scoped(input, result);
|
|
53
|
+
result.data = result.data.map((frame) => frame.in(scope));
|
|
54
|
+
return result;
|
|
38
55
|
}
|
|
39
56
|
/**
|
|
40
57
|
* `()` is nil, so a repetition left with no term at all answers nil:
|
|
@@ -218,7 +218,7 @@ export class FrameList extends Frame {
|
|
|
218
218
|
*/
|
|
219
219
|
holdsAsProperty(term) {
|
|
220
220
|
const binding = echoedBinding(this.answeredValue(term));
|
|
221
|
-
return binding !== undefined && binding.target
|
|
221
|
+
return binding !== undefined && binding.target === this;
|
|
222
222
|
}
|
|
223
223
|
size() {
|
|
224
224
|
return this.data.length;
|
|
@@ -50,7 +50,7 @@ export class FrameLiteral extends FrameAtom {
|
|
|
50
50
|
return this;
|
|
51
51
|
return new FrameLiteral(this.data, {
|
|
52
52
|
...this.binding,
|
|
53
|
-
target:
|
|
53
|
+
target: owner,
|
|
54
54
|
});
|
|
55
55
|
}
|
|
56
56
|
}
|
|
@@ -233,7 +233,7 @@ export class FrameSymbol extends FrameAtom {
|
|
|
233
233
|
out.set(assignmentKey, argument);
|
|
234
234
|
return previous.is.missing
|
|
235
235
|
? new FrameLiteral(`.${this.data} ${argument.toString()}`, {
|
|
236
|
-
target:
|
|
236
|
+
target: out,
|
|
237
237
|
key: assignmentKey,
|
|
238
238
|
value: argument,
|
|
239
239
|
})
|
|
@@ -264,7 +264,7 @@ export class FrameSymbol extends FrameAtom {
|
|
|
264
264
|
out.set(assignmentKey, schema);
|
|
265
265
|
out.set(`${assignmentKey}.<>`, schema);
|
|
266
266
|
return new FrameLiteral(`.${this.data} ${schema.toString()}`, {
|
|
267
|
-
target:
|
|
267
|
+
target: out,
|
|
268
268
|
key: assignmentKey,
|
|
269
269
|
value: schema,
|
|
270
270
|
});
|
|
@@ -18,11 +18,8 @@ export const HasType = (source, type) => {
|
|
|
18
18
|
export const BindType = (source, body) => {
|
|
19
19
|
if (source instanceof FrameLiteral && source.binding &&
|
|
20
20
|
body instanceof FrameLazy) {
|
|
21
|
-
const target = source.binding.target.deref();
|
|
22
|
-
if (!target)
|
|
23
|
-
return source;
|
|
24
21
|
body.bindSignature(source.binding.value);
|
|
25
|
-
target.set(source.binding.key, body);
|
|
22
|
+
source.binding.target.set(source.binding.key, body);
|
|
26
23
|
}
|
|
27
24
|
return source;
|
|
28
25
|
};
|
package/esm/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.24.
|
|
1
|
+
export const VERSION = "0.24.3";
|