Uploaded image for project: 'OASIS Open Document Format for Office Applications (OpenDocument) TC'
  1. OASIS Open Document Format for Office Applications (OpenDocument) TC
  2. OFFICE-3844

Semantics to function IF part 2, section 6.15.4, does not cover all syntax variants and is ambiguous in at least one case

    Details

    • Proposal:
      Hide

      Proposal:
      Semantics:
      Computes Condition. If it is TRUE, it returns IfTrue, else it returns IfFalse. This function only evaluates either IfTrue or IfFalse, and never both; that is to say, it short-circuits.

      Seven versions are possible:
      One parameter:
      a) IF(Condition)
      Two parameters:
      b) IF(condition
      c) IF(condition;IfTrue)
      Three parameters:
      d) IF(condition;
      e) IF(condition;;IfFalse)
      f) IF(condition;IfTrue
      g) IF(condition;IfTrue;IfFalse)

      If there is only 1 parameter (case a), IfTrue is considered to be TRUE() and IfFalse is considered to be FALSE(). Thus the 1 parameter version converts Condition into a Logical value.

      If there are 2 parameters (cases b and c), IfFalse is considered to be FALSE(). If there are 2 parameters and the second parameter is null (semicolon but no IfTrue, case b), IfTrue is considered to be 0.

      If there are 3 parameters but the second parameter is null (two consecutive ;; semicolons, cases d and e), IfTrue is considered to be 0.
      If there are 3 parameters but the third parameter is null (semicolon but no IfFalse, cases d and f), IfFalse is considered to be 0.

      Show
      Proposal: Semantics: Computes Condition. If it is TRUE, it returns IfTrue, else it returns IfFalse. This function only evaluates either IfTrue or IfFalse, and never both; that is to say, it short-circuits. Seven versions are possible: One parameter: a) IF(Condition) Two parameters: b) IF(condition c) IF(condition;IfTrue) Three parameters: d) IF(condition; e) IF(condition;;IfFalse) f) IF(condition;IfTrue g) IF(condition;IfTrue;IfFalse) If there is only 1 parameter (case a), IfTrue is considered to be TRUE() and IfFalse is considered to be FALSE(). Thus the 1 parameter version converts Condition into a Logical value. If there are 2 parameters (cases b and c), IfFalse is considered to be FALSE(). If there are 2 parameters and the second parameter is null (semicolon but no IfTrue, case b), IfTrue is considered to be 0. If there are 3 parameters but the second parameter is null (two consecutive ;; semicolons, cases d and e), IfTrue is considered to be 0. If there are 3 parameters but the third parameter is null (semicolon but no IfFalse, cases d and f), IfFalse is considered to be 0.

      Description

      When I resolve the optional parts [], I get seven valid syntax variants, here without data type.
      A: IF(Condition)
      B: IF(Condition
      C: IF(Condition;IfTrue)
      D: IF(Condition;
      E: IF(Condition;;IfFalse)
      F: IF(Condition;IfTrue
      G: IF(Condition;IfTrue;IfFalse)

      Some of them have missing parts. I should be able to determine the correct resulting value from the "Semantics"-part. But that is not possible for all variants.
      (use non-proportional font to get the table nice formatted)

      Condition |Condition |Text in part Semantics
      evaluates |evaluates |and the fitting syntax variants
      to TRUE |to FALSE |
      ---------------------------------------------------------
      result TRUE() | | "If there is only 1 parameter, IfTrue is

        considered to be TRUE()" fits to A
      -----------------------------------------------------------
      result FALSE() "If there are less than 3 parameters, IfFalse
        is considered to be FALSE()" fits to A,B,C
      ------------------------------------------------------------
      result 0 "If there are 2 or 3 parameters but the second
        parameter is null (two consecutive ;;
        semicolons), IfFalse is considered to be 0."
        fits to B,D,E, perhaps C fits too.
      ------------------------------------------------------------
      result 0 "If there are 3 parameters but the third
        parameter is null, IfFalse is considered to
        be 0." fits to D,F

      Problems:
      (1) Variants B and C are ambiguous, see row 2 and row 3
      (2) Why is a rule for IfFalse given, when the second parameter is missing, see row 3?
      (3) If the third parameter is not null but IfFalse, then IfFalse should be returned, if Condition is FALSE, but semantics say 0 in row 3.
      (4) For Condition TRUE in variants B, D and E no value for the missing second parameter is given. Perhaps the text "If there are 2 or 3 parameters but the second parameter is null (two consecutive ;;semicolons), IfTrue is considered to be 0." was intended?
      (5) It is not clear, whether C fits to row 3.

      Remarks.
      In variant B and C with condition FALSE, Gnumeric and Excel return FALSE
      In variant B,D, and E with condition TRUE, Gnumeric and Excel return 0 for the missing second parameter.
      In variant E with condition FALSE, Gnumeric and Excel return IfFalse and not 0.
      LibreOffice and AOO does not handle variants with ;; or

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              regina.henschel Regina Henschel
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: