Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread Paul King
I went to improve the documentation and found that "var == Object" is only in the variable definition section which, although no doubt could be improved, does seem correct. The fact that it works for property/field definitions (though not property accessor methods) is in part, as Eric mentioned, b

Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread MG
Hi Rémi, 1. yes, I saw that, thank you. 1. Most of the examples seemed obvious to me, and the bugs that could be introduced feel like they are a little bit on the artficial side. 2. But, having said that: Inferring an interface type or a less specific parent type in some case

Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread Guillaume Laforge
The venerable Groovy style guide (which could be updated a bit) recommends using def inside the body of methods and closures, and to use proper types for method signatures. In terms of updates, it could mention def or var. I'm used to use def, and am not u

Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread Gianluca Sartori
> > >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 la

Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread Gianluca Sartori
For me, def == var, in my mental model. Which means == Object. > This is how I was looking at it since that’s how it has been documented, but it has not been implemented that way. At this point of the discussion I understood it is a documentation issue, but still something in my mind is telling m

Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread MG
Hi Gianluca, 1. I fully agree with the documentation bit, and would also think it better if Java-syntax-compatibility Groovy constructs would be separated from idiomatic Groovy in e.g. a "Java syntax in Groovy" section :-) 1. With some constructs the only harm done is that ppl new to

Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread Gianluca Sartori
> > 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

Re: [EXT] Re: Using `var` as method return type placeholder

2024-11-26 Thread Jochen Theodorou
On 25.11.24 23:48, MG wrote: Hi Jochen, I am so glad that you are finally coming around to adding variable type inference to Groovy ||-) > Here are some links to get anyone started that wants to work on this: https://medium.com/javarevisited/local-variable-type-inference-in-java-use-of-var-59b