code change · featureAL Developmentofficial - Microsoftreviewed - checked by Opus

#136 Add community knowledge: AL boolean operators do not short-circuit

Two community knowledge articles explain AL's lack of short-circuit evaluation for boolean operators and recommend using case statements as alternatives for complex condition chains.

Pull request · merged into main on 2026-09-02 by aacnsilva · 6 files (+215 -0), 6 AL · feature · tier official · reviewed (checked by Opus)

What changed

  • AL gives no short-circuit guarantee for and, or or xor, so guards should not rely on operand order
  • Shows silent bugs such as reading a field from a record Get did not load, or evaluating an out-of-range subscript
  • For or, use an early exit (if A then exit(true); exit(B);) rather than the nested if rewrite used for and
  • Recommends case true/false of as a flat alternative once a guard chain goes past about three nested ifs
  • Includes good and bad AL samples for both articles

AL objects touched

  • community/knowledge/performance/boolean-operators-do-not-short-circuit.bad.al: added, not in the BC? snapshot yet
  • community/knowledge/performance/boolean-operators-do-not-short-circuit.good.al: added, not in the BC? snapshot yet
  • community/knowledge/performance/boolean-operators-do-not-short-circuit.md: added, not in the BC? snapshot yet
  • community/knowledge/performance/case-true-of-for-long-condition-chains.bad.al: added, not in the BC? snapshot yet
  • community/knowledge/performance/case-true-of-for-long-condition-chains.good.al: added, not in the BC? snapshot yet
  • community/knowledge/performance/case-true-of-for-long-condition-chains.md: added, not in the BC? snapshot yet

Context

  • Systems: development, platform
  • From the description: “AL gives no short-circuit (lazy) evaluation guarantee for and, or, or xor.”

Source: metadata of a merged pull request in microsoft/BCQuality (bcquality): title, labels, changed paths and counts, with a summary in our words. No source text and no description beyond one short quote (D10, D61).