Snow Leopard Code Blocks
I’ve recently been developing a Mac OS X project in which I was able to utilize the new code blocks feature to write some asynchronous code. They are a very exciting development, and I hope the C standards body adopts them as an official part of the language. They are similar to D’s delegates. A good introduction to blocks can be found in Apple’s Blocks Programming Topics.
I won’t explain what a block is here, other than to say it’s like a function. For a very brief introduction to the syntax of blocks, see “Declaring and Using a Block.”
What I will do is show you how code blocks can simplify inter-thread communication. First I’ll present a pre-code block approach to the problem, and then show how, by using code blocks, you can dramatically simplify the code.
Read more

