 # 3.2 Expression Calculation is a mixure of observations, rules and possible suggestions

XMLWordPrintable

#### Details

• Type: Bug
• Status: Applied
• Priority: Major
• Resolution: Fixed
• Affects Version/s: ODF 1.2 CD 05
• Fix Version/s:
• Component/s:
• Labels:
None
• Proposal:
Hide

NOTE: This is a revised proposal by David A. Wheeler, which attempts to merge the proposals by Eike, Wheeler, Patrick D., and others into a single clear result.

Fix Section 3.3 item 1.2 has some syntax errors, where it uses =ABS(A1:C1) instead of =ABS([.A1:.C1]) and so on.

Change entire section 3.2 Expression Calculation to:

Expressions in OpenFormula shall be evaluated by application of the following rules:

1. If an expression consists of a constant Number (per section 5.3), a constant String (per section 5.4), a Reference (per section 5.8), or constant Error (per section 5.12), the value of that type is returned.
2. If an expression consists of one or more operations (per sections 5.5 and 5.9), apply the operators in order of precedence and associativity as defined by Table 1 in 5.5 (Operators). Precedence of operators may be altered by the use of "(" (LEFT PARENTHESES, U+0028) and ")" (RIGHT PARENTHESES, U+0029) to group operators. Evaluate the operator as described below.
3. If an expression consists of a function call (per section 5.6 and 5.7), evaluate the function as described below.
4. If an expression consists of a named expression (per section 5.11), the result of evaluating the named expression is returned.
5. If an expression consists of an QuotedLabel (per section 5.10), AutomaticIntersection (per section 5.10), or Array (per section 5.13), its value is returned per section 5.

Operators and functions in OpenFormula are evaluated according to their definitions by applying the following rules:
1. The values of all argument expressions are computed. Exceptions to computation of all arguments are noted in a function's specification.
Note: The practice of computing all argument expressions is known as "eager" evaluation. The IF function is an example of a function that does not require computation of all arguments.
2. If an argument expression evaluates to Error, calculation of the operator or function may short-circuit and return the Error if the function does not suppress error propagation as noted in the function's specification.
3. If an operator or function is passed a value of incorrect type, call the appropriate implicit conversion function to convert the value to the correct type. If conversion is not possible, generate an Error.
4. The function or operation is called with its argument expressions' results (per rule 1), and the result of the function or operation is the evaluation of the expression.

Once evaluation has completed:
1. If the result is a Reference and a single non-reference value is needed, it is converted to the referenced value per the rules of section 3.3 (Non-Scalar Evaluation) item 1.2.
2. If the result is an Array, for the display area the rules of section 3.3 (Non-Scalar Evaluation) item 1.1 apply.

Show
NOTE: This is a revised proposal by David A. Wheeler, which attempts to merge the proposals by Eike, Wheeler, Patrick D., and others into a single clear result. Fix Section 3.3 item 1.2 has some syntax errors, where it uses =ABS(A1:C1) instead of =ABS( [.A1:.C1] ) and so on. Change entire section 3.2 Expression Calculation to: Expressions in OpenFormula shall be evaluated by application of the following rules: 1. If an expression consists of a constant Number (per section 5.3), a constant String (per section 5.4), a Reference (per section 5.8), or constant Error (per section 5.12), the value of that type is returned. 2. If an expression consists of one or more operations (per sections 5.5 and 5.9), apply the operators in order of precedence and associativity as defined by Table 1 in 5.5 (Operators). Precedence of operators may be altered by the use of "(" (LEFT PARENTHESES, U+0028) and ")" (RIGHT PARENTHESES, U+0029) to group operators. Evaluate the operator as described below. 3. If an expression consists of a function call (per section 5.6 and 5.7), evaluate the function as described below. 4. If an expression consists of a named expression (per section 5.11), the result of evaluating the named expression is returned. 5. If an expression consists of an QuotedLabel (per section 5.10), AutomaticIntersection (per section 5.10), or Array (per section 5.13), its value is returned per section 5. Operators and functions in OpenFormula are evaluated according to their definitions by applying the following rules: 1. The values of all argument expressions are computed. Exceptions to computation of all arguments are noted in a function's specification. Note: The practice of computing all argument expressions is known as "eager" evaluation. The IF function is an example of a function that does not require computation of all arguments. 2. If an argument expression evaluates to Error, calculation of the operator or function may short-circuit and return the Error if the function does not suppress error propagation as noted in the function's specification. 3. If an operator or function is passed a value of incorrect type, call the appropriate implicit conversion function to convert the value to the correct type. If conversion is not possible, generate an Error. 4. The function or operation is called with its argument expressions' results (per rule 1), and the result of the function or operation is the evaluation of the expression. Once evaluation has completed: 1. If the result is a Reference and a single non-reference value is needed, it is converted to the referenced value per the rules of section 3.3 (Non-Scalar Evaluation) item 1.2. 2. If the result is an Array, for the display area the rules of section 3.3 (Non-Scalar Evaluation) item 1.1 apply.
• Resolution:
Hide

General
OpenFormula defines rules for the evaluation of expressions as well as the functions and operators that appear in expressions.
Expression Calculation
Expressions in OpenFormula shall be evaluated by application of the following rules:
1)If an expression consists of a constant Number (5.3), a constant String (5.4), a Reference (5.8), constant Error (per section 5.12), the value of that type is returned.
2)If an expression consists of one or more operations, apply the operators in order of precedence and associativity as defined by Table 1 in 5.5 (Operators). Precedence of operators may be altered by the use of "(" (LEFT PARENTHESES, U+0028) and ")" (RIGHT PARENTHESES, U+0029) to group operators. Evaluate the operator as described in Operator and Function Evaluation, 3.2.3.
3)If an expression consists of a function call (5.6, 5.7), evaluate the function as described in Opertor and Function Evaluation, 3.2.3.
4)If an expression consists of a named expression (5.11), the result of evaluating the named expression is returned.
5)If an expression consists of a QuotedLabel (5.10), AutomaticIntersection (5.10.6), or Array (5.13), its value is returned. Expression Syntax 5
Once evaluation has completed:
1)If the result is a Reference and a single non-reference value is needed, it is converted to the referenced value, using the rules of Non-Scalar Evaluation, 3.3, 1.2.
2)If the result an Array, for the display area, apply the rules of Non-Scalar Evaluation, 3.3, 1.1.
Operator and Function Evaluation
Operators and functions in OpenFormula shall be evaluated according to their definitions by applying the following rules:
1)The value of all expression arguments are computed. Exceptions to computation of all arguments are noted in a function's specification.
Note: The practice of computing all argument expressions is known as "eager" evaluation. The IF function is an example of a function that does not require computation of all arguments.
2)If an argument expression evaluates to Error, calculation of the operator or function may short-circuit and return the Error if the function does not suppress error propagation as noted in the function's specification.
3)If an operator or function is passed a value of incorrect type, call the appropriate implicit conversion function to convert the value to the correct type. If conversion is not possible, generate an Error.
4)The function or operation is called with its argument expressions' results, and the result of the function or operation is the evaluation of the expression.

Show
General OpenFormula defines rules for the evaluation of expressions as well as the functions and operators that appear in expressions. Expression Calculation Expressions in OpenFormula shall be evaluated by application of the following rules: 1)If an expression consists of a constant Number (5.3), a constant String (5.4), a Reference (5.8), constant Error (per section 5.12), the value of that type is returned. 2)If an expression consists of one or more operations, apply the operators in order of precedence and associativity as defined by Table 1 in 5.5 (Operators). Precedence of operators may be altered by the use of "(" (LEFT PARENTHESES, U+0028) and ")" (RIGHT PARENTHESES, U+0029) to group operators. Evaluate the operator as described in Operator and Function Evaluation, 3.2.3. 3)If an expression consists of a function call (5.6, 5.7), evaluate the function as described in Opertor and Function Evaluation, 3.2.3. 4)If an expression consists of a named expression (5.11), the result of evaluating the named expression is returned. 5)If an expression consists of a QuotedLabel (5.10), AutomaticIntersection (5.10.6), or Array (5.13), its value is returned. Expression Syntax 5 Once evaluation has completed: 1)If the result is a Reference and a single non-reference value is needed, it is converted to the referenced value, using the rules of Non-Scalar Evaluation, 3.3, 1.2. 2)If the result an Array, for the display area, apply the rules of Non-Scalar Evaluation, 3.3, 1.1. Operator and Function Evaluation Operators and functions in OpenFormula shall be evaluated according to their definitions by applying the following rules: 1)The value of all expression arguments are computed. Exceptions to computation of all arguments are noted in a function's specification. Note: The practice of computing all argument expressions is known as "eager" evaluation. The IF function is an example of a function that does not require computation of all arguments. 2)If an argument expression evaluates to Error, calculation of the operator or function may short-circuit and return the Error if the function does not suppress error propagation as noted in the function's specification. 3)If an operator or function is passed a value of incorrect type, call the appropriate implicit conversion function to convert the value to the correct type. If conversion is not possible, generate an Error. 4)The function or operation is called with its argument expressions' results, and the result of the function or operation is the evaluation of the expression.

#### Description

3.2 Expression Calculation is a mixture of observations, rules and possible suggestions.

For example, it starts by saying formulas are recalculated from "outside in," only to confess a few paragraphs later that is how it "appears to the end user."

There is one really glaring hole in my proposal, that also exists in the current language.

We describe the ordering of operators but as far as I can tell, we don't address the situation where there is a mixture of operators and functions.

Note that I changed #1 from constant number/string and added error.

As near as I can determine, the only possible outcomes of any expression are:

1) a number

2) a string

3) an error

4) a reference

So, application of these rules self-terminates when any of those conditions obtain.

Yes, that removes "constant number," "constant string" but those are defined elsewhere anyway.

#### People

• Assignee: Eike Rathke (Inactive)
Reporter: Patrick Durusau
• Watchers:
1 Start watching this issue

#### Dates

• Created:
Updated:
Resolved: