On 25.11.24 10:34, Gianluca Sartori wrote:
> Because var currently only exists in Groovy to be Java syntax compatible. My opinion is that this should be documented as such then, because right now it's been documented as an alias for `def` but it is not.
+1
> Doing so would prevent a possible future extension of Groovy to do type inference where var is used. What use cases require type inference in Groovy? Would it be useful only when coupled with @CompileStatic? Are there use cases where it is useful also with @CompileDynamic?
if you have code like this: def m(int i) { return i+1 } Here you know i is an int, and then you can do a guarded version of static compilation that avoids all the boxing and dynamic method calls. This is then quite a bit faster on early executions. We used this before invokedynamic quite a bit. But that is not really connected to var. bye Jochen