Lunderberg opened a new pull request, #13432:
URL: https://github.com/apache/tvm/pull/13432
Even though the operator precedence of `And` has a higher precedence than
`Or`, removing parentheses based on this precedence can harm readability. This
commit adds an exception to the TVMScript rules for parentheses, to always
insert parentheses between `And` and `Or` operators.
In addition, adding a rewrite rule to preferentially produce And/Or chains
that may be expressed in a single left-associative chain of operators.
Between these two changes, the readability of boolean expressions can be
improved. Below is the motivating example for this change. In each case, the
output had been passed through the `black` formatter. Both expressions are
equivalent, but the before-case was much more difficult to read.
```python
x = (
AAA == 0
and BBB < 4
or AAA == 7
and 6 <= BBB
or (CCC == 0 and DDD < 4 or CCC == 7 and 6 <= DDD)
)
x = (
(AAA == 0 and BBB < 4)
or (AAA == 7 and 6 <= BBB)
or (CCC == 0 and DDD < 4)
or (CCC == 7 and 6 <= DDD)
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]