groovy-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Sun <>
Subject 答复: About the "implies" operator(GROOVY-2576)
Date Thu, 26 Jan 2017 09:18:59 GMT
Hi Cédric,

     Here is the background of the “implies” operator, which is well known in the mathematical
logic ??

发件人: Cédric Champeau [via Groovy]<>
发送时间: 2017年1月26日 17:12
收件人: Daniel Sun<>
主题: Re: About the "implies" operator(GROOVY-2576)

I'm not convinced we should add more operators. Honestly, I had to read the description of
the "implies" operator to understand what it does. This is clearly not the case for || or
&&, which are "well known" operators.

I am also worried about code becoming ascii art:

{ a -> a => a <= c => d }

So I'm just +0, I don't see that I would use it often enough to mitigate the drawbacks.

2017-01-26 1:47 GMT+01:00 Daniel Sun <[hidden email]</user/SendEmail.jtp?type=node&node=5738104&i=0>>:
Hi Jochen,

      Thanks for your analysis in detail :)

       => is a very expressive operator. if we could implement it as +(corresponding to
plus method) does and apply different business logic when necessary, it would be much more
useful. And the default implementation of "implies" method can be "!a||b".

        As to the association of the operator, I prefer the left association, i.e. a =>
b => c is equivalent to (a => b) => c.

       The above is the initial plan to implement the  "implies" operator.


在 2017年1月26日 上午3:20,"Jochen Theodorou [via Groovy]" <ml-node+s329449n5738042h6
On 25.01.2017 17:50, Daniel Sun wrote:

> Hi all,
>        The "implies" operator "=>" was suggested many years ago, here is the
> replated JIRA issue( GROOVY-2576
> <>  ) .
>        Do you want it for Groovy 3? (+1: yes; -1: no; 0: not bad)
>        BTW, recently I have been going through the issues related to the old
> parser, many issues existing for many years do not exist in the new parser
> Parrot :)

If we do this (and I say +1) we should clear some things:
1) what does a=>b=>c mean, since (a=>b)=>c is not the same as a=>(b=>c)
2) use groovy truth and when to apply it? If we map a=>b to !a||b, then
it will use Groovy truth on a and b, but if we map to an implies method
it will get a and b, use groovy truth on them or not and we then maybe
use groovy truth on the result. I personally would be for not using
groovy truth here, thus make it more in line with | and &.
3) if a=>b is mapped to !a||b we will evaluate a, negate it, and
depending on the result maybe never evaluate b. As long as a and b are
free of side effects, that does not play an extremely important role,
but if we map it to a method a and b will be evaluated always. If we
would say it is more like !a|b, which would also require both being
evaluated, then there is still the fact that !a ensures we call here
always the boolean or function, never one defined by an arbitrary a
4) instead of using !a, which converts a to a boolean and negates it, we
can also use ~a, which is a binary negate also working on booleans, but
not converting a to a boolean if it is no boolean. Here we have to
especially think about ~a|b calling "or" on a Pattern if a is a String.
Also not many things besides boolean and numbers really support
something useful of the binary negate.

I mention those points so we can make a proper specification for the
behaviour of this operator ;)

bye Jochen

If you reply to this email, your message will be added to the discussion below:
To unsubscribe from About the "implies" operator(GROOVY-2576), click here.

View this message in context: Re: About the "implies" operator(GROOVY-2576)<>

Sent from the Groovy Dev mailing list archive<>

If you reply to this email, your message will be added to the discussion below:
To unsubscribe from About the "implies" operator(GROOVY-2576), click here<>.

View this message in context:
Sent from the Groovy Dev mailing list archive at
View raw message