Method References

Joshua Bloch jjb at google.com
Fri Feb 26 08:40:47 PST 2010


I agree that method references would be a fine addition to the proposal, and
I like the proposed syntax. I believe it's important that method references
work for constructors and static methods as well as instance methods.

I am very much in favor of allowing the user to omit the type information
when it's unambiguous.  In fact, is their any reason to use "this" (as
proposed by Fredrick):

    cb = this#saveState;

or could we allow:

    cb = #saveState;

Not only is this more succinct, but it mirrors the rules for method
invocation, allowing "reasoning by analogy" and reducing programmer
astonishment.

            Josh

On Fri, Feb 26, 2010 at 8:15 AM, Neal Gafter <neal at gafter.com> wrote:

> On Fri, Feb 26, 2010 at 2:45 AM, Rémi Forax <forax at univ-mlv.fr> wrote:
>
> > there is a source compatibility issue if you allow to not specify the
> type.
> >
> > class A {
> >   void m(String s) { ... }
> > }
> > ....
> > ref = A#m;
> >
> > Now suppose I want to add a new method m(Integer),
> >
>
> Adding a new method to a class is not a source-compatible change today.
>  However, it is a binary-compatible change today and both with and without
> method references and with or without the proposed method reference
> argument
> inference.
>
>


More information about the lambda-dev mailing list