3 ms·
"C blocks" == closures?
by JulianMorrison 17y ago
"C blocks" == closures?
- baxter 17y agoThey don't sound far off. Wikipedia agrees with you so far :) http://en.wikipedia.org/wiki/Blocks_%28C_language_extension%29 http://en.wikipedia.org/wiki/Blocks_%28C_language_extension%... The Ars Technica review of Snow Leopard features a nice introduction to the new language feature: http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.ars/10 http://arstechnica.com/apple/reviews/2009/08/mac-os-x-10-6.a...
- silentbicycle 17y agoThey're immutable, though. (For sake of parallelization.)
- JulianMorrison 17y agoPretty similar to Java anonymous inner instances of Runnable and Callable, then.
- nevyn 17y agoExcept 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.
- JulianMorrison 17y agoThey 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.
- eru 17y agoProper closures in a pure language are immutable, too.
- silentbicycle 17y agoWell, sure, but that's not usually what people are talking about when they mean closures.
- gloob 17y agoDepending 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.
- deleted 17y ago[deleted]