Next: , Previous: Late Function Arguments Evaluation, Up: Expression Evaluator

2.18 Optimizing Expressions

Expression optimization may (well, it should) reduce the evaluation time and the storage and evaluation memory requirements. However, since the optimization logic is not fast as compared to the evaluation logic, optimizing expression is usually pointless for one time evaluations.

The expression evaluator can performed a few basic expression optimizations, such as complex constant subexpression elimination, identity (or neutral) element elimination for operations defining one (such as addition and multiplication), etc.

Most optimizations are generic, that is the optimizer does not have built-in knowledge of operator properties such as the addition operator (`+') properties and is instead deriving the possible optimization from the operator definition.

Hmm, forget about that, the operator optimization extensions are not described yet.

Expression can be optimized through the x1f4_line_expression function.

See x1f4_line_expression.

No side effects operators (X1f4_LEFT_XSET marked) and no application indicated as having side effects (X1f4_KEEP_CALL marked) functions and operators are optimized away.

See Infix Binary Operator Flags.

See Operator And Function Flags.

The optimizer does not expect void function to not have side effects, hence attempts to optimize expression referring void functions not being indicated as having side effects (X1f4_KEEP_CALL marked) should only be considered as alternatives to: