-
Notifications
You must be signed in to change notification settings - Fork 590
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hclsyntax: && and || operators are right-associative
Previously we just treated all binary operators as being left-associative, which for many of them didn't make a lot of difference anyway because they were associative operators. The logical AND and OR operators are also effectively associative the way we have them implemented right now, because HCL always evaluates both sides of a binary operator anyway and so there's no way to depend on the associativity for either of these operations. However, we'd like to implement a similar short-circuit behavior as we see in many other similar languages, at which point the evaluation order of the operations would become important in order to constrain which expressions get fully evaluated and which are "short-circuited". Treating these operators as right-associative instead of left-associative will make the subsequent implementation more intuitive, since the LHS of the outermost operation will decide whether to evaluate the RHS, rather than recursing into the LHS completely first and then unwinding if the innermost term causes the short-circuit. Since we expect HCL expression evaluation to always be side-effect-free it doesn't technically matter what associativity we use -- the result would be the same either way -- but this approach will make the control flow during evaluation match intuition about how a short-circuit behaves. This commit does not yet actually implement the short-circuit behavior, which will hopefully follow in a subsequent commit.
- Loading branch information
1 parent
b440b17
commit 9ba6757
Showing
3 changed files
with
220 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters