>
>
>    1. Do you maybe have a link to the "using 'var' in Groovy code" talk
>    you mention ?
>
>
It was an online meeting, the idea is using var to be more
appealing/familiar to Java developers so to attract them. Actually there is
a link but we kind of went berserk, so if you want to have a laugh here it
is, take it with a grain of salt, you may come out with some info or at
least get entertained a bit :))

https://github.com/orgs/grails/discussions/13842

Cheers,
Gianluca

>
>    1.
>
> Cheers,
> mg
>
>
> On 26/11/2024 10:10, Gianluca Sartori wrote:
>
> I have the feeling that your confusion comes from the fact that you think
>> Groovy = Python in the Java world, and Python def = Java var, therefore
>> Groovy var should be def.
>>
>
> Well, my confusion comes from the documentation (
> https://groovy-lang.org/semantics.html#_variable_definition) that states:
>
> > If you think of def and var as an alias of Object, you will understand
> in an instant.
>
> So I understood the wrong thing instantly :)
>
> There are tons of constructs Groovy supports for the sole reason to be as
>> copy & paste compatible with Java as possible (Java-style curly-braces
>> literal arrays, Java for-each loops, etc, etc), and none of these are first
>> class citizens / idiomatic Groovy.
>> The var reserved word, that as a technicality is currently mapped to def
>> with some restrictions, is just a small blip in a large sea here.
>>
>
> Okay then I guess that this should be clear from the documentation.
> Because they can be seen as new features of the language we should use to
> stay updated. I mean we should not even talk about `var` in the same place
> we are documenting `def`, there should be a separate chapter "Compatibility
> with Java".
>
> I use `def` everywhere when writing the higher/final layer of my software
> (Eg, not the internal API layers where I prefer to use types to self
> document the code) this `var` topic I am discussing here was triggered by a
> talk I've heard about starting to use 'var' in Groovy code.
>
> Cheers,
> Gianluca
>
>
>

Reply via email to