You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@groovy.apache.org by Paul King <pa...@asert.com.au> on 2018/04/10 07:00:45 UTC
Compound assignment for logic operators
Hi Everyone,
I noticed that the '&&=' and '||=' operators (LOGICAL_AND_EQUAL and
LOGICAL_OR_EQUAL) are partially supported in a few parts of the codebase
but not at the grammar level. Does anyone remember any previous discussion
about those operators?
Thanks, Paul.
Re: Compound assignment for logic operators
Posted by mg <mg...@arscreat.com>.
Hi Paul,
do you have a use case for these operators in mind ? I guess some sort of "an error has occurred" boolean flag aggregation could profit from that:
boolean errorQ = false
errorQ ||= foo0(...)errorQ ||= foo1(...)errorQ ||= foo2(...)...
if(errorQ) { throw new Exception("some error occurred.. ")}
Cheers,mg
-------- Ursprüngliche Nachricht --------Von: Paul King <pa...@asert.com.au> Datum: 11.04.18 11:47 (GMT+01:00) An: dev@groovy.apache.org Betreff: Re: Compound assignment for logic operators
It seems older than that. I guess we decided to follow java and C rather than Ruby.I suspect we wouldn't want to make an override-able operator for logical and/or but I see no harm in having the short-hand itself.Anyway, we can look at it if there is sufficient interest.
Cheers, Paul.
On Wed, Apr 11, 2018 at 2:58 AM, Jochen Theodorou <bl...@gmx.org> wrote:
Am 10.04.2018 um 09:00 schrieb Paul King:
Hi Everyone,
I noticed that the '&&=' and '||=' operators (LOGICAL_AND_EQUAL and LOGICAL_OR_EQUAL) are partially supported in a few parts of the codebase but not at the grammar level. Does anyone remember any previous discussion about those operators?
I don't really remember... did we maybe add it for groovypp?
bye Jochen
Re: Compound assignment for logic operators
Posted by Paul King <pa...@asert.com.au>.
It seems older than that. I guess we decided to follow java and C rather
than Ruby.
I suspect we wouldn't want to make an override-able operator for logical
and/or but I see no harm in having the short-hand itself.
Anyway, we can look at it if there is sufficient interest.
Cheers, Paul.
On Wed, Apr 11, 2018 at 2:58 AM, Jochen Theodorou <bl...@gmx.org> wrote:
>
>
> Am 10.04.2018 um 09:00 schrieb Paul King:
>
>>
>> Hi Everyone,
>>
>> I noticed that the '&&=' and '||=' operators (LOGICAL_AND_EQUAL and
>> LOGICAL_OR_EQUAL) are partially supported in a few parts of the codebase
>> but not at the grammar level. Does anyone remember any previous discussion
>> about those operators?
>>
>
> I don't really remember... did we maybe add it for groovypp?
>
> bye Jochen
>
Re: Compound assignment for logic operators
Posted by Jochen Theodorou <bl...@gmx.org>.
Am 10.04.2018 um 09:00 schrieb Paul King:
>
> Hi Everyone,
>
> I noticed that the '&&=' and '||=' operators (LOGICAL_AND_EQUAL and
> LOGICAL_OR_EQUAL) are partially supported in a few parts of the codebase
> but not at the grammar level. Does anyone remember any previous
> discussion about those operators?
I don't really remember... did we maybe add it for groovypp?
bye Jochen