You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (JIRA)" <ji...@apache.org> on 2016/06/02 07:08:59 UTC

[jira] [Comment Edited] (GROOVY-6148) Multiple definition should allow final

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

Paul King edited comment on GROOVY-6148 at 6/2/16 7:08 AM:
-----------------------------------------------------------

Changing the {{multipleAssignmentDeclarationStart}} definition in the grammar from:
{code}
(modifier nls | annotation nls)* "def" nls LPAREN
{code}
to
{code}
(modifier nls | annotation nls | "def" nls)+ LPAREN
{code}
Seems to be the change required. And seems like a reasonable change for modifiers.

It does make the use of attributeless annotations a little confusing. Not that we currently support it but if you wanted to have something like @Lazy annotating a multi-assignment, you would need need something like:
{code}
@Lazy() (x, y) = [1, 2]
{code}
Note the empty brackets after @Lazy which could normally be elided but not here. Otherwise the (x, y) would be mistaken as attributes for the annotation. Note: the @Lazy example above is just fictitious. It currently knows nothing about multi-assignments, so the above is NOT supported.


was (Author: paulk):
Changing the {{multipleAssignmentDeclarationStart}} definition in the grammar from:
{code}
(modifier nls | annotation nls)* "def" nls LPAREN
{code}
to
{code}
(modifier nls | annotation nls | "def" nls)+ LPAREN
{code}
Seems to be the change required. And seems like a reasonable change for modifiers.

It does make the use of attributeless annotations a little confusing. Not that we currently support it but if you wanted to have something like @Lazy annotating a multi-assignment, you would need need something like:
{code}
@Lazy() (x, y) = [1, 2]
{code}
Note the empty brackets after @Lazy which could normally be elided but not here. Otherwise the (x, y) would be mistaken as attributes for the annotation.

> Multiple definition should allow final
> --------------------------------------
>
>                 Key: GROOVY-6148
>                 URL: https://issues.apache.org/jira/browse/GROOVY-6148
>             Project: Groovy
>          Issue Type: Bug
>          Components: syntax
>            Reporter: Russel Winder
>
> The line:
> {quote}
> def (x, y) = l.split()
> {quote}
> works fine. However, the line:
> {quote}
> final (x, y) = l.split()
> {quote}
> fails with a compile error. If def gives a rebindable variable and final gives an unrebindable variable in other places it should here as well.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)