3 ms·
Which isn't true anyway, since anonymous inner classes are just very verbose and awkward lambdas. (I'm a Java hater but I'm also a horrible pedant)
by spacemanaki 15y ago
Which isn't true anyway, since anonymous inner classes are just very verbose and awkward lambdas. (I'm a Java hater but I'm also a horrible pedant)
- djacobs 15y agoTrue. Then again, what's the practical point of lambdas that aren't concisely expressed?
- spacemanaki 15y agoThere are plenty of practical uses: http://code.google.com/p/guava-libraries/wiki/FunctionalExplained http://code.google.com/p/guava-libraries/wiki/FunctionalExpl... Note that the Guava lib specifically points out how ugly this is. I prefer Clojure.
- baddox 15y agoWhat's the decision procedure for whether a certain expression is "concise?"
- batista 15y agoHorrible as in "no good" pedant? Because, no "anonymous inner classes" are no lambdas. They are, well, classes kludgily used to mimic a lambda proper.
- lubutu 15y agoWhat it is to be 'a lambda' isn't particularly well-defined. If we define it to mean an anonymous closure then Java certainly has them — so long as its free variables are final (it closes over references). On the other hand, if we define it as the operator which creates anonymous closures, then Java doesn't, because you have to actually build the closure by hand. Since the former have a proper name (closures) and the latter doesn't, I'd be inclined to call only the operator a 'lambda'. But since you can at least 'approximate' closures in Java (with anonymous inner classes), I think it's fair to say that they are "very verbose and awkward lambdas", to some definition of lambda.
- spacemanaki 15y agolordlicorice (the ggp of my post) suggested that there is "no substitute for lambdas" and I was intending to correct that. Anonymous inner classes are definitely a substitute.