paulk-asert commented on PR #1560:
URL: https://github.com/apache/groovy/pull/1560#issuecomment-1498759057
I am inclined to close this. While I think the goal of having the English
equivalents is a nice idea and handy for certain DSL scenarios, I think there
are enough problems to outweigh having that built-in to the language.
Firstly, for code as shown in the issue, e.g. "if(validated or
administrator){", the conditional expression will normally be parsed as the
following command chain "validated(or).administrator". Similarly for "and". You
would need to write "validated.or(administrator)" if you didn't like "validated
|| administrator" or "validated | administrator". So, you would need a little
bit of DSL processing code with property missing or similar to actually make
"and" and "or" work as described.
Secondly, there might be confusion in that "not" isn't our mechanism for
operator overloading "!", whereas "or" and "and" are our mechanism for
overloading "&" and "|". We kind of treat "&&", "||" and "!" specially. We use
"asBoolean" to override Groovy truth and then "&&", "||" and "!" just work with
the results from Groovy truth. There is nothing stopping folks from defining
their own "not" method, and they can tailor the definition to their DSL
scenario.
--
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]