On 23/11/2024 13:43, Gianluca Sartori wrote:
When we use @CompileStatic or @TypeChecked we are declaring we care about types.

Groovy always cares about the types of variables (unless you use def/Object, which is a design choice) - the question is only whether it checks for correct types during compile (@CompileStatic/@TypeChecked) or runtime (@CompileDynamic, or, more precisely @TypeChecked(TypeCheckingMode.SKIP) (the default)).

That said, why should we make a Groovy `var` that is not exactly the same as the Groovy `def`?

Because:

1. var currently only exists in Groovy to be Java syntax compatible.
2. var implies something different, more restricted than def (see
   replies by other mailing list members).
3. Doing so would prevent a possible future extension of Groovy to do
   type inference where var is used.

Cheers,
mg



Reply via email to