groovy-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "tinne (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GROOVY-7935) Right side of assignment - remove parens or not?
Date Mon, 03 Oct 2016 20:13:20 GMT

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

tinne commented on GROOVY-7935:
-------------------------------

Looks like I stumbled over the fact that {{groovysh}} is even less groovyish than I expected,
as I falsely derived by assumptions from whatever happens here:

{code:java}
groovy:000> bar = { -> 1 }
===> groovysh_evaluate$_run_closure1@5812f68b
groovy:000> m = bar
===> groovysh_evaluate$_run_closure1@5812f68b
groovy:000> m()
===> 1
{code}

This seems to be yet something different, as the following assignment gives a different closure
behaving the same way:

{code:java}
groovy:000> m = this.&bar
===> org.codehaus.groovy.runtime.MethodClosure@5e4bd84a
groovy:000> m()
===> 1
{code}


> Right side of assignment - remove parens or not?
> ------------------------------------------------
>
>                 Key: GROOVY-7935
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7935
>             Project: Groovy
>          Issue Type: Bug
>          Components: Documentation
>         Environment: http://groovy-lang.org/style-guide.html, release 2.4.7
>            Reporter: tinne
>            Assignee: John Wagenleitner
>            Priority: Minor
>             Fix For: 2.4.8
>
>
> The Groovy [style guide|http://groovy-lang.org/style-guide.html] says, "...  Groovy doesn’t
allow you to remove parentheses. [...] for nested method calls or on the right-hand side of
an assignment, you can’t omit them there."
> Then, a code fragment is given, where just this works.
> {noformat}
> def foo(n) { n }
> println foo 1 // won't work, as documented
> def m = foo 1 // this works indeed!
> {noformat}
> Further more, I could not find any examples, where this would not work, neither with
comma separated parameter lists nor with infix computations nor closures.
> So I guess it is just a documentation bug and right-hand side parens removal support
has been added.



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

Mime
View raw message