From bb92dab1abab356b129f64bcf010cc1afcdf4c1f Mon Sep 17 00:00:00 2001 From: Dianne Skoll Date: Sat, 1 Jun 2024 16:44:37 -0400 Subject: [PATCH] More docs. --- src/expr.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/expr.c b/src/expr.c index 42605bdb..15482b3b 100644 --- a/src/expr.c +++ b/src/expr.c @@ -85,6 +85,31 @@ | VARIABLE | | CONSTANT | | x | | 4 | +----------+ +----------+ + + Evaluation is done recursively from the root of the tree. To + evaluate a node N: + + 1) Evaluate node N's children from left to right + 2) Apply the operator or function to all of the resulting values + + For nodes without children, the result of evaluation is: + 1) For N_CONSTANT nodes: The constant + 2) For N_VARIABLE nodes: The value of the variable + 3) For N_SYSVAR nodes: The value of the system variable + 4) For N_LOCAL_VAR nodes: The value of the user-defined functions argument + + User-defined functions contain their own expr_node tree. This is + evaluated with the "locals" parameter set to the values of all + of the function's arguments. + + Some operators don't evaluate all of their children. For example, + the || and && operators always evaluate their leftmost child. If + the result is true for ||, or false for &&, then the rightmost child + is not evaluated because its value is not needed to know the result + of the operator. + + The built-in functions choose() and iif() also perform this sort of + short-circuit evaluation. */ /* Constants for the "how" arg to compare() */