c++objective-cclangobjective-c-blocksclang-extensions

How do Clang 'blocks' work?


http://clang.llvm.org/docs/BlockLanguageSpec.txt

Looks really cool.

However,

  1. I don't understand it.
  2. I don't see examples it.
  3. I don't see examples of ideas hard to express in C++ as is, but trivial to express in blocks.

Can anyone enlighten me on this?


Solution

  • Blocks are, essentially, a way to pass code and scope around as data. They're known in some other languages as closures and anonymous functions.

    Here's an article with more details and code examples.