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

They're immutable, though. (For sake of parallelization.)


Proper closures in a pure language are immutable, too.


Well, sure, but that's not usually what people are talking about when they mean closures.


Depending on how pure the language is, /variables/ can be immutable. Nonetheless, the standard, default, run-of-the-mill variables that most programmers will run into most of the time are not. Same goes for closures.


Pretty similar to Java anonymous inner instances of Runnable and Callable, then.


Except those can't read nor modify variables in their enclosing scope. Anonymous inner instances are more akin to C's nested functions, which GCC has had for a long time.

Correct me if I'm wrong though (which would only make me very happy); been years since I did Java.


They can read and modify object fields in their outer class's instance. But it's true they can't modify stack variables. This makes contextual sense - C blocks are being stack allocated and have to be explicitly copied to the heap. Java inner instances get copied immediately, because everything lives on the heap in Java.




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

Search: