Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Ah, I see. Thanks.


> Java's lambdas don't support mutation of captured variables

I've never used Java 8 lambdas but that sounds the same as Java's inner classes which I'm now guessing lambdas are syntactic sugar for. I remember the common trick with inner classes to enable mutation was to declare and initialize a size 1 array of the required type instead of the type itself, and refer to, say, myvar[0] instead of myvar inside the class. I'm guessing this would then work with Java 8 lambdas also.

> Java's lambdas aren't real closures, though. Are Groovy's?

I last used Groovy at version 1.8 so don't remember for sure but think they did allow mutation. Groovy's closures also have the delegate lookup flag to enable dynamic scoping of names within closure code passed around and executed later, which I don't imagine lambdas have. Such a trick is done with macros in lisps like Clojure.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: