septima-lang 0.0.14 → 0.0.15

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.
@@ -1,7 +1,5 @@
1
- import { AstNode, Lambda, UnitId } from './ast-node';
1
+ import { AstNode, Lambda } from './ast-node';
2
2
  import { CallEvaluator } from './find-array-method';
3
- import { Span } from './location';
4
- import * as Stack from './stack';
5
3
  import { SymbolTable } from './symbol-table';
6
4
  declare type LambdaEvaluator = (names: string[], ast: AstNode, table: SymbolTable) => Value;
7
5
  declare type Inner = {
@@ -22,16 +20,12 @@ declare type Inner = {
22
20
  } | {
23
21
  tag: 'num';
24
22
  val: number;
23
+ } | {
24
+ tag: 'undef';
25
+ val: undefined;
25
26
  } | {
26
27
  tag: 'obj';
27
28
  val: Record<string, Value>;
28
- } | {
29
- tag: 'sink';
30
- val: undefined;
31
- span?: Span;
32
- trace?: Stack.T;
33
- symbols?: SymbolTable;
34
- unitId?: UnitId;
35
29
  } | {
36
30
  tag: 'str';
37
31
  val: string;
@@ -41,27 +35,12 @@ export declare class Value {
41
35
  private constructor();
42
36
  static bool(val: boolean): Value;
43
37
  static num(val: number): Value;
44
- /**
45
- * Returns a Value which is essentially a "sink": (almost) every computation involving a sink evaluates to sink. A few
46
- * quick examples: `5+sink`, `sink.x`, `sink()`, `Object.keys(sink)`, `if (sink) 4 else 8` all evaluate to `sink`. The
47
- * raitonale is that once an expression evaluates to `sink` all expressions depending on it also evaluate to `sink`.
48
- *
49
- * There are however a few (intentional) exemptions:
50
- * (i) a sink can be passed as an actual parameter in a function call. Hence `(fun (x,y) y)(sink, 5)` will evaluate
51
- * to `5`.
52
- * (ii) a sink can be compared with itself.
53
- * (iii) in `if()` expressions, only one of the branches is evlauated (based on the condition's value). As a result,
54
- * evluation of a sink-producing branch can be skipping. Specifically, `if (true) 5 else sink` evaluates to `5`.
55
- * (iv) in `||` and `&&` expressions, the evaluation of the right hand side can be skipped. Specifically,
56
- * `true || sink` evaluates to `true` and `false && sink` evaluates to `false`.
57
- */
58
- static sink(span?: Span, trace?: Stack.T, symbols?: SymbolTable, unitId?: UnitId): Value;
59
38
  static str(val: string): Value;
39
+ static undef(): Value;
60
40
  static arr(val: Value[]): Value;
61
41
  static obj(val: Record<string, Value>): Value;
62
42
  static lambda(ast: Lambda, table: SymbolTable): Value;
63
43
  static foreign(f: (...args: Value[]) => unknown): Value;
64
- isSink(): boolean;
65
44
  unwrap(): unknown;
66
45
  assertBool(): boolean;
67
46
  assertNum(): number;
@@ -73,17 +52,11 @@ export declare class Value {
73
52
  table: SymbolTable;
74
53
  };
75
54
  isLambda(): boolean;
55
+ isUndefined(): boolean;
76
56
  ifElse(positive: () => Value, negative: () => Value): Value;
77
- bindToSpan(span: Span, unitId?: UnitId): Value;
78
- trace(): AstNode[] | undefined;
79
- symbols(): SymbolTable | undefined;
80
- where(): {
81
- span: Span;
82
- unitId: string;
83
- } | undefined;
57
+ coalesce(that: () => Value): Value;
84
58
  or(that: () => Value): Value;
85
59
  and(that: () => Value): Value;
86
- unsink(that: () => Value): Value;
87
60
  equalsTo(that: Value): Value;
88
61
  not(): Value;
89
62
  private binaryNumericOperator;
@@ -125,6 +98,8 @@ export declare class Value {
125
98
  entries(): Value;
126
99
  fromEntries(): Value;
127
100
  toString(): string;
101
+ toBoolean(): boolean;
102
+ toNumber(): number;
128
103
  toJSON(): unknown;
129
104
  export(): unknown;
130
105
  static from(u: unknown): Value;