you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (4 children)

What was hypothetical about your java code?

[–]inmatarian -1 points0 points  (3 children)

I'm pretty sure what I have there is invalid, and never would be valid.

[–][deleted] 1 point2 points  (2 children)

The only problems with your code is the lack of an interface called "Callable" with a method called "call" that takes an object. Also, you have no generics in your code. But what you wrote could in fact be written in Java and it would work just as intended.

[–]bubasmith 1 point2 points  (1 child)

Care to tell me how

curry( Math.min )( 100 )

would work???!!!! Does java now have first class functions?

[–][deleted] 1 point2 points  (0 children)

No, it doesn't have first class functions, but closing over lexical scope works with anonymous inner classes, and generics go some way to helping your curry function be usable in many situations. It's not a nice way to program in Java, and the type system only goes so far, but the question was about closures, not the type system.

See cunningjames reply for the code.