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.

dust192B
#_ada {name Ada
       role engineer
       age  36}
#_bob {name   Bob
       role   engineer
       age    41
       mentor {#link #_ada}}
#_cy  {name Cy
       role designer
       age  29}

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.

dust9B
[+ ?x 1]
Result / 2B
x
41
42

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.

dust8B
[/ 1 0]

Error

Runtime_Failure: The divisor must not be zero.

Run it

build · program evaluate.