|
| 1 | +# MeTTaScript 2.4.0 |
| 2 | + |
| 3 | +A native fast path for the functions that destructure data. A deterministic function that matches on its |
| 4 | +argument's constructor — an evaluator over an expression tree, a symbolic transformer like differentiation, |
| 5 | +an environment lookup — now compiles to a native switch on the constructor that returns its result |
| 6 | +directly, instead of rebuilding an intermediate atom at every step for the evaluator to re-reduce. Removing |
| 7 | +that per-step allocation is the win. Every terminating program produces the same output as 2.3.1, validated |
| 8 | +byte-identical across the full corpus, so upgrading is safe. |
| 9 | + |
| 10 | +## Native scalar dispatch |
| 11 | + |
| 12 | +When a function's clauses are mutually exclusive on their head constructor and its bodies stay within |
| 13 | +arithmetic, constructor construction, and recursive calls over the destructured children, the whole function |
| 14 | +compiles to native code: it dispatches on the argument's constructor, binds the children, evaluates the body |
| 15 | +with native arithmetic and direct recursive calls, and returns a bare value or a directly built atom — no |
| 16 | +result bag, no per-node atom allocation, no round trip back through the evaluator. Clauses outside that |
| 17 | +subset, non-ground calls, and any runtime rule change fall back to the interpreter, and the compiled and |
| 18 | +fallback clauses are proven pairwise exclusive so the direct return is sound. |
| 19 | + |
| 20 | +Integer, floating-point, atom-returning, and mixed-return functions are all covered, with `3` and `3.0` kept |
| 21 | +distinct and the interpreter's numeric coercion matched exactly. The compiled recursion shares the same |
| 22 | +evaluation-depth accounting as the interpreter, so a deep computation cuts at the `max-stack-depth` bound at |
| 23 | +exactly the same place with the same `StackOverflow`, and runs native the whole way through a raised bound. |
| 24 | + |
| 25 | +On an interpreter over a large expression tree the evaluation runs 3 to 5 times faster and holds 25 to 40 |
| 26 | +percent less heap; a symbolic differentiation at a raised depth bound runs about 2.2 times faster with 40 |
| 27 | +percent less peak memory. Output stays byte-identical in every case. |
| 28 | + |
| 29 | +## Docs |
| 30 | + |
| 31 | +The site description now matches the rest of the positioning: a metagraph database and reasoning engine you |
| 32 | +drive from TypeScript, not only a query store. |
| 33 | + |
1 | 34 | # MeTTaScript 2.3.1 |
2 | 35 |
|
3 | 36 | A patch fix for the native-stack recovery path added in 2.3.0. When a very deep structural comparison |
|
0 commit comments