Straw man section 7: Method References
David Goodenough
david.goodenough at linkchoose.co.uk
Mon Dec 14 07:38:58 PST 2009
A field reference is a means to get rid of String literal field names from
places like Beans, Beans Bindings, and JPA. String literal fields are
uncheckable by compilers/IDEs, IDEs can not refactor them and can
not provide context assist for them.
The type of a Field Reference would either (as in the FCM case for a Method
Reference) be a java.lang.reflect.Field, or if you read my first reply to
Paul you will see that I would suggest that compound #s are really
what is needed, in which case a simple wrapper class (say FieldRef/MethodRef)
would be needed.
Its relationship to lambda, or rather closures, is I grant indirect. It is
that in many respects Fields and Methods are similar, or rather Field
and Method objects are similar (in the way they are acquired at least)
and so if one was being done I asked whether the other could be considered
given that the heavy lifting of syntax change would already be in place.
David
On Monday 14 December 2009, Mark Mahieu wrote:
> Before diving into syntax, I think I might first like to know what a field
> literal is supposed to be in this context - for starters, what type does
> it have (is it the same as in FCM, or something else?), and how does it
> relate to lambdas?
>
> Mark
>
> On 14 Dec 2009, at 14:26, Paul Benedict wrote:
> > David,
> >
> > I find your suggestion interesting. If # helps grab a method literal,
> > what syntax can grab a field literal? Do you have anything in mind?
> >
> > Paul
> >
> > On Mon, Dec 14, 2009 at 6:30 AM, David Goodenough
> >
> > <david.goodenough at linkchoose.co.uk> wrote:
> >> I realise that this section is TBD, but can I ask whether Field
> >> References could also be considered at the same time. I realise that
> >> they are not really part of closures, but once the basic syntax is in
> >> place for Method References then Field References are a simple
> >> extension.
> >>
> >> I can outline why I think it important to do Field References, but if
> >> you regard it as totally out of court there is little point in starting.
> >> I would however be very keen to help if this could be added, and I
> >> believe that it would benefit Java to add this functionality. It is not
> >> a large change, there are no JVM changes required and only one extra
> >> library
> >> class required of which I already have a prototype.
> >>
> >> David
>
More information about the lambda-dev
mailing list