paulk-asert commented on code in PR #1999:
URL: https://github.com/apache/groovy/pull/1999#discussion_r1407059329
##########
src/antlr/GroovyParser.g4:
##########
@@ -848,6 +848,9 @@ expression
// logical or (||) (level 13)
| left=expression nls op=OR nls right=expression
#logicalOrExprAlt
+ // implication (==>) (level 13.5)
+ | <assoc=right> left=expression nls op=IMPLIES nls right=expression
#implicationExprAlt
Review Comment:
Looking into the reasoning behind Dafny's choice it is because implication
is often read like the ternary operator (which is right associative).
So, elaborating on the example I gave in the issue, you might see (if Groovy
had a framework like Dafny's):
```
@Ensures(@ForAll int i, @ForAll int j, { i, j ->
i in 0..<items.size() && j in 0..<items.size() ==>
i <= j ==>
result[i] <= result[j]
})
List<String> sort(List<String> items) {
// sort method here
}
```
All of Dafny's other operators match what we have, i.e. right associative
for assignment/ternary but left elsewhere.
But if you have a strong counter example/counter argument we can switch it
back.
--
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]