groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mg (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-8300) Groovy should have an @AutoFinal annotation
Date Sun, 27 Aug 2017 16:38:00 GMT

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

mg commented on GROOVY-8300:
----------------------------

My main rationale for suggesting this feature was for _final parameters_, i.e. having the
easier to read / less cluttered
{code}
foo(String name, boolean trimQ, boolean indentLinesQ, boolean keepEmptyLinesIndentationQ,
boolean seperateFunctionsQ, boolean uppercaseKeywordsQ, boolean uppercaseNamesQ) { }
{code}
instead of
{code}
foo(final String name, final boolean trimQ, final boolean final indentLinesQ, final boolean
keepEmptyLinesIndentationQ, final boolean seperateFunctionsQ, final boolean uppercaseKeywordsQ,
final boolean uppercaseNamesQ) { }
{code}
in my code everywhere, while still
# being sure that all parameters could not be reassigned in the method body, and
# potentially allowing the compiler to optimize the code accordingly (Note: According to [~blackdrag],
no such optimizations are currently applied).






> Groovy should have an @AutoFinal annotation
> -------------------------------------------
>
>                 Key: GROOVY-8300
>                 URL: https://issues.apache.org/jira/browse/GROOVY-8300
>             Project: Groovy
>          Issue Type: New Feature
>            Reporter: Paul King
>
> When defined on a method or constructor, all parameters of that method/constructor will
be final. When applied on a class, the annotation applies to all methods/constructors.
> Still to be determined:
> # Should visibility matter, e.g. would it apply to all public, protected, private, etc.
members, or does there need to be some ability to customise?
> # Should the annotation apply to fields/properties? Applying 'final' to a field/property
seems to be more efficient than applying @AutoFinal but would there ever be a desire to apply
such an annotation to all fields/properties?



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Mime
View raw message