groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mgroovy (JIRA)" <>
Subject [jira] [Commented] (GROOVY-8570) Support Warnings in Groovy Compiler
Date Fri, 11 May 2018 14:50:00 GMT


mgroovy commented on GROOVY-8570:

@[~paulk]: The question this boils down to for me is: Are you OK with e.g. Groovy devs which
use JavaScript using var instead of def in their Groovy code, because they are used to it
and maybe think it is the better name anyway - and never change that behavior ? None of your
suggestions addresses that problem, it is all about freedom and people discovering the Groovy
way over time. But with syntax there is no such thing, def is not superior to var in any way,
and someone (not me) could actually argue that var would be the better choice over def, since
JavaScript uses it...

(I also would like to point out again, that if people start using var in place of def, then
introducing type-safe var semantics in the future, would lead to a breaking change in Groovy,
so there are actually two good reasons why it would be smart to nudge people to avoid using
the var syntax when writing Groovy code).

So my point is about _100%_ _redundant_ _syntax,_ whereas you talk about _non-redundant_
_language usage choices_, such as Java-style for-loops vs Groovy-functional-style each. Apart
from the fact that the former is faster due to not requiring a closure, both of these have
their applications, and I would have no intention to warn about their usage...


> Support Warnings in Groovy Compiler
> -----------------------------------
>                 Key: GROOVY-8570
>                 URL:
>             Project: Groovy
>          Issue Type: New Feature
>          Components: Compiler
>    Affects Versions: 3.0.0-alpha-3
>            Reporter: mgroovy
>            Priority: Major
> * To warn Java developers using e.g. non-idiomatic Groovy constructs which only exist
to support copy-and-paste Java-to-Groovy code compatibility, The Groovy compiler should support
compiler warnings in addition to compiler errors.
>  * Warnings should by default only be emitted in special circumstances such as the one
described above, and not spam developers with an endless stream of, often subjectve, messages
on "how to use Groovy correctly".
>  * Sample warnings:
> # WARNING: Using curly braces Java style array literals (\{...}) is not idiomatic Groovy.
To avoid confusion with Groovy closures, it is recommended to use the performance-identical
Groovy square bracket list literal syntax ([...]) instead.
> # WARNING: The 'var' keyword is currently only an alias to 'def' (i.e. Object) in Groovy.
To get reassignment type safety use an explicit type instead.

This message was sent by Atlassian JIRA

View raw message