Type Annotations and Lambda
Werner Dietl
wdietl at gmail.com
Thu Feb 7 17:52:14 PST 2013
Thanks for the clarifications, Maurizio and Alex!
I now have the examples that I needed and am close to finishing the
implementation of that part.
cu, WMD.
On Thu, Feb 7, 2013 at 3:40 PM, Alex Buckley <alex.buckley at oracle.com> wrote:
> On 2/5/2013 2:19 PM, Werner Dietl wrote:
>>
>> I am waiting on a specification clarification from Mike and/or Alex
>> about METHOD_REFERENCE_RECEIVER and CONSTRUCTOR_REFERENCE_RECEIVER.
>> To me these don't look like type uses, but instead only like scoping
>> mechanisms, for which we don't support type annotations.
>> It would be great to see a few examples of type uses for these and
>> what the interpretation of type annotations should be.
>
>
> I just spoke with Mike about this, and things are as intended.
>
> Suppose I have an interface IntMapper<T> whose single method is "int map(T
> t)". Then I write:
>
> IntMapper<@Vernal Date> x = { @Vernal Date d -> BODY };
> int i = x.map(new @Vernal Date());
>
> If I promise that BODY extracts and returns the day from d, then i will be
> 7, right? Now suppose I write:
>
> IntMapper<@Vernal Date> x = @Vernal Date::getDay;
> int i = x.map(new @Vernal Date());
>
> i will also be 7 here. The method reference expression is just a lambda
> expression in disguise. "Date" is not a scoping mechanism but rather the
> type of the first formal parameter of the implicit lambda expression.
>
> I concede that "RECEIVER" in the enum constant is confusing. The receiver is
> really the IntMapper instance. We'll rename those two constants.
>
> Alex
--
http://www.google.com/profiles/wdietl
More information about the type-annotations-dev
mailing list