Evaluating
An expression becomes a program before it runs. Expressions describes its values. Compilation and execution determine how it runs. The native API accepts documents for the program and its input variables.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 000 | 54 52 4F 4E | magic TRON |
| 004 | 3C 616765 | txt "age" |
| 008 | 02 24000000000000 00 | i64 36 |
| 011 | 0F 0A 04000000 0800 0000 | map leaf, size 10: @4 → @8 |
| 01B | 4C 726F6C65 | txt "role" |
| 020 | 8C 656E67696E6565 72 | txt "engineer" |
| 029 | 0F 0A 1B000000 2000 0000 | map leaf, size 10: @1B → @20 |
| 033 | 4C 6E616D65 | txt "name" |
| 038 | 3C 416461 | txt "Ada" |
| 03C | 0F 0A 33000000 3800 0000 | map leaf, size 10: @33 → @38 |
| 046 | 07 12 00910000 1100 0000 29000000 3C00 0000 | map branch, size 18, depth 0 (root), slots 8, 12, 15: @11 → @29 → @3C |
| 058 | 5C 236C696E6B | txt "#link" |
| 05E | 5C 235F616461 | txt "#_ada" |
| 064 | 0F 0A 58000000 5E00 0000 | map leaf, size 10: @58 → @5E |
| 06E | 3C 616765 | txt "age" |
| 072 | 02 29000000000000 00 | i64 41 |
| 07B | 0F 0A 6E000000 7200 0000 | map leaf, size 10: @6E → @72 |
| 085 | 6C 6D656E746F72 | txt "mentor" |
| 08C | 0F 0A 85000000 6400 0000 | map leaf, size 10: @85 → @64 |
| 096 | 4C 726F6C65 | txt "role" |
| 09B | 8C 656E67696E6565 72 | txt "engineer" |
| 0A4 | 0F 0A 96000000 9B00 0000 | map leaf, size 10: @96 → @9B |
| 0AE | 4C 6E616D65 | txt "name" |
| 0B3 | 3C 426F62 | txt "Bob" |
| 0B7 | 0F 0A AE000000 B300 0000 | map leaf, size 10: @AE → @B3 |
| 0C1 | 07 16 00990000 7B00 0000 8C000000 A400 0000 B7000000 | map branch, size 22, depth 0 (root), slots 8, 11, 12, 15: @7B → @8C → @A4 → @B7 |
| 0D7 | 3C 616765 | txt "age" |
| 0DB | 02 1D000000000000 00 | i64 29 |
| 0E4 | 0F 0A D7000000 DB00 0000 | map leaf, size 10: @D7 → @DB |
| 0EE | 4C 726F6C65 | txt "role" |
| 0F3 | 8C 64657369676E65 72 | txt "designer" |
| 0FC | 0F 0A EE000000 F300 0000 | map leaf, size 10: @EE → @F3 |
| 106 | 4C 6E616D65 | txt "name" |
| 10B | 2C 4379 | txt "Cy" |
| 10E | 0F 0A 06010000 0B01 0000 | map leaf, size 10: @106 → @10B |
| 118 | 07 12 00910000 E400 0000 FC000000 0E01 0000 | map branch, size 18, depth 0 (root), slots 8, 12, 15: @E4 → @FC → @10E |
| 12A | 4C 235F6379 | txt "#_cy" |
| 12F | 0F 0A 2A010000 1801 0000 | map leaf, size 10: @12A → @118 |
| 139 | 5C 235F626F62 | txt "#_bob" |
| 13F | 0F 0A 39010000 C100 0000 | map leaf, size 10: @139 → @C1 |
| 149 | 5C 235F616461 | txt "#_ada" |
| 14F | 0F 0A 49010000 4600 0000 | map leaf, size 10: @149 → @46 |
| 159 | 07 12 80210000 2F01 0000 3F010000 4F01 0000 | map branch, size 18, depth 0 (root), slots 7, 8, 13: @12F → @13F → @14F |
| 16B | 59010000 00000000 | root → @159; previous: none |
Stored expressions
A stored expression has a title and an authored program document. Saving it validates compilation. A successful definition commit records its new revision. An inline program needs no database. Both forms use the same evaluator.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 1C 2B | txt "+" |
| 06 | 2C 3F78 | txt "?x" |
| 09 | 02 01000000000000 00 | i64 1 |
| 12 | 0E 15 00 0700 030000 00 04000000 060000 00 09000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @9 |
| 27 | 12000000 00000000 | root → @12; previous: none |
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 02 2A000000000000 00 | i64 42 |
| 0D | 04000000 00000000 | root → @4; previous: none |
Maximum cost
The evaluation cost measures CPU time on the execution thread. The public API reports 100-nanosecond ticks. The cost limit uses the same unit. It includes input preparation, execution, native helpers and native result construction.
A positive limit permits execution until the evaluator detects that the budget is exhausted. Checks occur during execution and after result construction. A helper can cross the limit before the next check. Zero leaves a standalone evaluation without an explicit limit. Query budgets have additional rules in Bounds.
Errors
Compilation rejects an unknown operator or an invalid argument count. Evaluation rejects an invalid value type, arithmetic overflow or division by zero. The native diagnostic identifies the error and gives its explanation.
| Offset (hex) | Bytes (hex) | Meaning |
|---|---|---|
| 00 | 54 52 4F 4E | magic TRON |
| 04 | 1C 2F | txt "/" |
| 06 | 02 01000000000000 00 | i64 1 |
| 0F | 02 00000000000000 00 | i64 0 |
| 18 | 0E 15 00 0700 030000 00 04000000 060000 00 0F000000 | array leaf, size 21, shift 0, bitmap 0007, count 3 (root): @4 → @6 → @F |
| 2D | 18000000 00000000 | root → @18; previous: none |
Error
Runtime_Failure: The divisor must not be zero.