Re: About creating instances of non-static inner classes with Java-Like syntax

2018-04-11 Thread Paul King
One of the more common forms of array creation is catered for in the Parrot
parser.


On Thu, Apr 12, 2018 at 3:36 AM,  wrote:

> I know it is part of the Java spec, but do you know anyone that actuallky
> does that?  I'm just curious as I've never once seen a need for it.
>
> Array creation is the one item that comes up most often for me when
> converting a source file from Java to Groovy.
>
>


Re: About creating instances of non-static inner classes with Java-Like syntax

2018-04-11 Thread Remko Popma
Eric,

Yes this is used. 

For example, picocli has an Ansi enum (ON, OFF, AUTO), with a nested inner 
class Text. 

A Text instance is created with 
`currentAnsi.new Text(“@|bold hello|@“);`
The outer class determines whether Ansi escape codes are emitted when the text 
is rendered. 

I’m sure it’s possible to design things differently but if you are asking “is 
this actually used“, the answer is yes. 

(Shameless plug) Every java main() method deserves http://picocli.info

> On Apr 12, 2018, at 2:36,  
>  wrote:
> 
> I know it is part of the Java spec, but do you know anyone that actuallky 
> does that?  I'm just curious as I've never once seen a need for it.
> 
> Array creation is the one item that comes up most often for me when 
> converting a source file from Java to Groovy.
> 


RE: About creating instances of non-static inner classes with Java-Like syntax

2018-04-11 Thread eric.milles
I know it is part of the Java spec, but do you know anyone that actuallky does 
that?  I'm just curious as I've never once seen a need for it.

Array creation is the one item that comes up most often for me when converting 
a source file from Java to Groovy.



Re: About creating instances of non-static inner classes with Java-Like syntax

2018-04-11 Thread Daniel.Sun
Here is the test: 
https://github.com/danielsun1106/groovy-parser/blob/new-non-static-inner-class/src/test/resources/core/NonStaticClass_01x.groovy

Cheers,
Daniel.Sun



--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html


About creating instances of non-static inner classes with Java-Like syntax

2018-04-11 Thread Daniel.Sun
Hi all,

   When I tried to carry out the step1 of Phoenix plan( i.e. make Parrot
support Java syntax as a dialect), I found Groovy does not support  some
code like `outer.new Inner()` to create instances of non-static inner
classes[1]. So I set aside some time to support the syntax in the Parrot
parser[2].  I wish you would like it.

P.S. "Differences with Java"[1] is a bit outdated for Groovy 3 ;-)

Cheers,
Daniel.Sun
[1] http://groovy-lang.org/differences.html
[2]
https://github.com/danielsun1106/groovy-parser/tree/new-non-static-inner-class




--
Sent from: http://groovy.329449.n5.nabble.com/Groovy-Dev-f372993.html


Re: Compound assignment for logic operators

2018-04-11 Thread mg
Since Java using the operator for something else in the future seems unlikely, 
and confusing it with the bitwise variety can already happen for the 
non-assignment version, I feel adding/activating &&= and ||= would put another 
arrow in the Groovy quiver...
 Ursprüngliche Nachricht Von: Jochen Theodorou 
 Datum: 11.04.18  14:37  (GMT+01:00) An: 
dev@groovy.apache.org Betreff: Re: Compound assignment for logic operators 


Am 11.04.2018 um 13:56 schrieb mg:
> Wait - since when does Java have logical or and and assignment 
> operators... ?-)

it does not? ups... yes... |= and not ||=

Strange... I thought I used it before in Java or Groovy... I had a very 
specific code in mind for that actually...


Re: Compound assignment for logic operators

2018-04-11 Thread mg
Maybe ||= was active in Groovy at some point ?Or you used |= and Groovy truth 
made it work ?||-)
 Ursprüngliche Nachricht Von: Jochen Theodorou 
 Datum: 11.04.18  14:37  (GMT+01:00) An: 
dev@groovy.apache.org Betreff: Re: Compound assignment for logic operators 


Am 11.04.2018 um 13:56 schrieb mg:
> Wait - since when does Java have logical or and and assignment 
> operators... ?-)

it does not? ups... yes... |= and not ||=

Strange... I thought I used it before in Java or Groovy... I had a very 
specific code in mind for that actually...


Re: Compound assignment for logic operators

2018-04-11 Thread Jochen Theodorou



Am 11.04.2018 um 13:56 schrieb mg:
Wait - since when does Java have logical or and and assignment 
operators... ?-)


it does not? ups... yes... |= and not ||=

Strange... I thought I used it before in Java or Groovy... I had a very 
specific code in mind for that actually...


Re: Compound assignment for logic operators

2018-04-11 Thread mg
Wait - since when does Java have logical or and and assignment operators... ?-)
 Ursprüngliche Nachricht Von: Jochen Theodorou 
 Datum: 11.04.18  12:58  (GMT+01:00) An: 
dev@groovy.apache.org Betreff: Re: Compound assignment for logic operators 


Am 11.04.2018 um 12:44 schrieb mg:
> 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:

In Java I use that all the time (sometimes to the dismay of my 
colleagues), so far I had no need for this in Groovy.. strange actually.

bye Jochen


Re: Compound assignment for logic operators

2018-04-11 Thread Jochen Theodorou



Am 11.04.2018 um 12:44 schrieb mg:

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:


In Java I use that all the time (sometimes to the dismay of my 
colleagues), so far I had no need for this in Groovy.. strange actually.


bye Jochen


Re: Compound assignment for logic operators

2018-04-11 Thread mg
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  
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  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