Primitives in Generics
jkuhnert at gmail.com
Fri Jul 9 16:08:37 PDT 2010
Indeed, I have a feeling that anyone with a keyboard and search engine
is going to have a hard time matching up the current proposal with the
promise of closures - if and when it does make it out into the wild.
Java developers get ragged on enough as it is, no one can say for
~sure~ what the reaction will be except maybe time and loss of market
Certainly not the most glorious first major release for Oracle to show
the world what the new deal will be with java, but the market has
rewarded them so far so why would it stop? ( of course there's that
pesky issue of not having sun around anymore to feed off of but that
probably won't matter)
On Friday, July 9, 2010, Neal Gafter <neal at gafter.com> wrote:
> On Fri, Jul 9, 2010 at 3:36 PM, Pavel Minaev <int19h at gmail.com> wrote:
> C# lambda expressions and anonymous delegate expressions are not of
> delegate types. C# 4.0 language specification, section 7.15 "Anonymous
> function expressions":
> "An anonymous function is an expression that represents an
> “in-line” method definition. An anonymous function does not have a
> value or type in and of itself, but is convertible to a compatible
> delegate or expression tree type."
> That is compatible with what I described. Any given lambda expression in any given valid C# program has a
> delegate type which is selected by target-typing. But the target type is required (i.e., the lambda does not have a type in and of itself independent of the target of the conversion). BGGA works that way too; that aspect of project lambda does not bother me at all.
> So far as I can see, C# has precisely the same limitations here as the
> proposed no-function-types-but-SAM-conversion for Java.
> C# lambdas bind names lexically. The proposed lambdas do not.
> C# lambdas bind "this" lexically. The proposed lambdas do not.
> C# "function types" (delegates) are typically defined to be covariant in return types and contravariant in argument types. SAMs cannot be so defined.
> C#'s generic delegate types such as Func<Arg,Return> can specialize over primitives and over different numbers of arguments. SAMs cannot.
> C# lambdas can bind mutable local variables. The proposed lambdas do not.
> C# lambdas can infer lambda argument types even when passed as an argument to an overloaded method. The proposed lambdas do not.
> The point, anyway, is that C# has had this construct, whatever the
> name, for 5 years now, and it has a success story to tell. If Java
> "closure-like construct" is on par with that, it's good enough for me
> and all the people who have been happy with that aspect of C#.
> It doesn't appear that it is likely to be on par.
More information about the lambda-dev