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

ASF GitHub Bot commented on GROOVY-7772:
----------------------------------------

GitHub user uehaj opened a pull request:

    https://github.com/apache/groovy/pull/287

    Javalike method pointer groovy 7772

    This is a change for method pointer semantics in groovy discussed in 
following issue.
    https://issues.apache.org/jira/browse/GROOVY-7772
    
    ref.
    
http://docs.groovy-lang.org/latest/html/documentation/index.html#method-pointer-operator
    
https://docs.oracle.com/javase/tutorial/java/javaOO/methodreferences.html#type


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/uehaj/groovy 
javalike-method-pointer-GROOVY-7772

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/groovy/pull/287.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #287
    
----
commit 0308f6fe44ba354ba3eaf61d45f924895d09483d
Author: UEHARA Junji <[email protected]>
Date:   2016-03-07T21:18:54Z

    GROOVY-7772: Change method pointer like Java 8

commit f2ab90ea1ee0960d2a87b0feb536c4134841eb82
Author: UEHARA Junji <[email protected]>
Date:   2016-03-08T20:00:44Z

    GROOVY-7772: Add test cases.

commit 280a27b6b4715d153e01258670dda5131ebed187
Author: UEHARA Junji <[email protected]>
Date:   2016-03-08T20:28:32Z

    GROOVY-7772: Handle too few arguments as missing method exception.

----


> Class.&instanceMethod had better to have same meaning of 
> Class::instanceMethod of Java8
> ---------------------------------------------------------------------------------------
>
>                 Key: GROOVY-7772
>                 URL: https://issues.apache.org/jira/browse/GROOVY-7772
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-runtime
>    Affects Versions: 2.4.6
>            Reporter: UEHARA Junji
>            Assignee: Jochen Theodorou
>            Priority: Minor
>
> Groovy's operator .& for method is similar functionality to Java8's method 
> reference operator ::.
> ||No.||lhs||rhs||meaing of Groovy's .& (Closure) ||meaning of java8's :: 
> (FunctionalInterface)||
> |1|instance|instanceMethod| { ..args -> instance.instanceMethod(args) | same 
> as groovy |
> |2|Class|staticMethod| { ..args -> Class.staticMethod(args) | same as groovy |
> |3|instance|staticMethod| ERROR groovy.lang.MissingMethodException: | Error 
> same as groovy (compile error) |
> |4|Class|instanceMethod|error| Function<RetType,Class,Args..>, where method 
> instance method of Class which is declared as ```RetType 
> instanceMethod(Args..) {...}```. In other words it is interpreted as a 
> function which takes LHS Class as the first parameter which additionally 
> inserted to the method.)|
> IMHO, i'd like to propose to change the No 4 pattern semantics of groovy  
> same as Java 8 's. Because:
>  * You can write:
> {code}
> ["a,b,c"].collect ( String.&toUpperCase )
> {code}
> instaed of
> {code}
> ["a,b,c"].collect { it.toUpperCase() }
> {code}
> * Can have correspond operator to java8's ::. which is understandablea and 
> needed for Java programmers.



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

Reply via email to