Primitives in Generics
Rémi Forax
forax at univ-mlv.fr
Fri Jul 9 15:42:49 PDT 2010
Le 09/07/2010 21:38, Brian Goetz a écrit :
>>> ... some mad professor cooked up :) :) :)
>>>
>> My take is that you have three choices:
>> A) Support function types covering primitives
>> B) Support primitives in generics
>> C) Do something that doesn't restrict your options to reconsider
>> (A) or (B) in Java8 in response to all the complaints about
>> sucky parallel performance.
>>
> Indeed so. We believe we have chosen (C). If we have not, please say
> something!
>
>
something! :)
The latest proposal don't tell the story to go from C to A or B,
and I doubt it's possible.
Let suppose, we want to add 'apply' to collection API,
with the proposed scheme, we will have something like this:
interface Function<T> {
void invoke(T element);
}
interface Collection<E> {
...
extension void apply(Function<? super E> function)
default Collections.apply;
}
class Collections {
...
static <T> void apply(Collection<? extends T> c, Function<? super T>
function) {
for(T element: c) {
function.invoke(element);
}
}
}
I don't see a *binary* backward compatible way to introduce function
types later.
Rémi
More information about the lambda-dev
mailing list