groovy-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jochen Theodorou <>
Subject Re: Possible New Groovy Features... - Auto final-ize
Date Fri, 25 Aug 2017 08:01:18 GMT

On 23.08.2017 00:32, MG wrote:
> Apart from making the code easier to
> read & safer, it also allows compiler optimizations (and in the absence
> of a true const-keyword, at least for fundamental data types it has the
> same effect).

Something I want to mention here: The Groovy compiler currently contains 
no optimizations for final local variables. The JIT has optimizations 
for final fields, but for local variables the final modifier is just 
removed even in Java. There are of course optimizations that can be done 
if something is final, which is to use a change-only-referenced logic 
instead of a change-variable-itself logic for inner classes, lambdas and 
closures. But right now we do not have this kind of optimization in the 

That of course still means there is the read&safer part. Just not sure 
what you mean by safer actually.

>> Also, it would be an easy task to create an @AutoFinal local transform
>> which could then be automatically applied using a compiler customizer.
>> I think going further with a dedicated compiler flag would be a later
>> step if such a local transform became extremely popular.
> Never found the need to do my own AST transforms in Groovy - do you
> maybe have a pointer to a current tutorial on how to get started for me
> ? Since you mentioned macros in your reply, I first went "Do we have
> these in Groovy ?", then I found I checked out the 2.5 macro description
> - do you think it would be worth waiting for 2.5 to become stable to be
> able to use macros for this functionality ?

you can use it already. The macros will most likely not change a lot 
anymore, unless we find problems, which then you could for example help 
us finding then ;)

bye Jochen

View raw message