AddLetVar adds a let variable to the evaluation context. The expression is planned but evaluated lazily.
(name string, expr string, typeHint *envlib.TypeDesc)
| 610 | // AddLetVar adds a let variable to the evaluation context. |
| 611 | // The expression is planned but evaluated lazily. |
| 612 | func (e *Evaluator) AddLetVar(name string, expr string, typeHint *envlib.TypeDesc) error { |
| 613 | // copy the current context and attempt to update dependant expressions. |
| 614 | // if successful, swap the current context with the updated copy. |
| 615 | ctx := e.ctx.copy() |
| 616 | ctx.addLetVar(name, expr, typeHint) |
| 617 | err := updateContextPlans(ctx, e.env) |
| 618 | if err != nil { |
| 619 | return err |
| 620 | } |
| 621 | e.ctx = *ctx |
| 622 | return nil |
| 623 | } |
| 624 | |
| 625 | // AddLetFn adds a let function to the evaluation context. |
| 626 | func (e *Evaluator) AddLetFn(name string, params []letFunctionParam, resultType *envlib.TypeDesc, expr string) error { |