Skip to main content

Neal Gafter: A Syntax Option for Project Lambda (Closures for Java)

Neal Gafter discusses A Syntax Option for Project Lambda (Closures for Java):

It was noted recently on the Project Lambda mailing list that allowing arrays of function type would undermine the type system. The reason for this is a combination of Java's covariant arrays, the natural subtypes among function types (they are covariant on return type and contravariant on argument types), exception checking, and the erasure implementation of generics. We certainly can't remove covariant arrays or checked exceptions, and removing the subtype relationship among function types really reduces their utility. Unfortunately, it is almost certainly too late to reify generics too...

Community: OpenJDK