You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "paulk-asert (via GitHub)" <gi...@apache.org> on 2023/11/27 10:14:47 UTC
[PR] GROOVY-11238: Logical implication operator revisited [groovy]
paulk-asert opened a new pull request, #1999:
URL: https://github.com/apache/groovy/pull/1999
(no comment)
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-11238: Logical implication operator revisited [groovy]
Posted by "daniellansun (via GitHub)" <gi...@apache.org>.
daniellansun commented on code in PR #1999:
URL: https://github.com/apache/groovy/pull/1999#discussion_r1407754977
##########
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:
LGTM
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-11238: Logical implication operator revisited [groovy]
Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-11238: Logical implication operator revisited [groovy]
Posted by "daniellansun (via GitHub)" <gi...@apache.org>.
daniellansun commented on code in PR #1999:
URL: https://github.com/apache/groovy/pull/1999#discussion_r1406945262
##########
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:
Logical Operators are left-associative, I think we do not need the assoc option.
For example,
a ==> b ==> c
should be parsed as
(a ==> b) ==> c
See also https://stackoverflow.com/questions/39317938/associativity-and-precedence-of-java-operators-in-antlrv4-grammar
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-11238: Logical implication operator revisited [groovy]
Posted by "daniellansun (via GitHub)" <gi...@apache.org>.
daniellansun commented on PR #1999:
URL: https://github.com/apache/groovy/pull/1999#issuecomment-1827717571
+1
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-11238: Logical implication operator revisited [groovy]
Posted by "daniellansun (via GitHub)" <gi...@apache.org>.
daniellansun commented on code in PR #1999:
URL: https://github.com/apache/groovy/pull/1999#discussion_r1406945262
##########
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:
Logical Operators are left-associative, I think we do not need the assoc option.
See also https://stackoverflow.com/questions/39317938/associativity-and-precedence-of-java-operators-in-antlrv4-grammar
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] GROOVY-11238: Logical implication operator revisited [groovy]
Posted by "paulk-asert (via GitHub)" <gi...@apache.org>.
paulk-asert merged PR #1999:
URL: https://github.com/apache/groovy/pull/1999
--
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: notifications-unsubscribe@groovy.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org