[ 
https://issues.apache.org/jira/browse/GROOVY-8570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16465225#comment-16465225
 ] 

mgroovy commented on GROOVY-8570:
---------------------------------

@[~emilles]: The difference to the scenario you describe here is not that the 
language use is "preferred" but actually the right way to use Groovy: 
Constructs such as Java style array literals or var as alias for def exist 
_solely_ for copy-and-paste Java compatibility. I.e. you are not supposed to 
use them if you are writing Groovy code. If a developer still wants to ignore 
that, there is nothing stopping him from silencing the warnings.

As I said, these warnings are not intended for seasoned Groovy devs, nor should 
they ever see them, but to inform Java devs copy-and-paste-"porting" code from 
Java that, while certain Java constructs are syntactically supported by Groovy, 
it makes no sense to use them when writing Groovy code, since Groovy has its 
own, more precise / better fitting syntax to achieve the same result.

> Support Warnings in Groovy Compiler
> -----------------------------------
>
>                 Key: GROOVY-8570
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8570
>             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
(v7.6.3#76005)

Reply via email to