Tornado and Grand Central Dispatch: a quick look
Tornado and Grand Central Dispatch: a quick look
Posted Sep 16, 2009 18:33 UTC (Wed) by wahern (subscriber, #37304)Parent article: Tornado and Grand Central Dispatch: a quick look
Blocks aren't restricted to read-only access to the outer scope. You can qualify auto objects with "__block". Similar to the "register" qualifier, you're not allowed to take a pointer to the object; neither from the Block nor the outer function. But, this allows the Block to modify the value of the object.
It's just a small step, then, to allow full read-write access without requiring the programmer to qualify the storage type. The compiler could detect expressions--and does, I'm sure--which modify the object, and automagically change it's storage type. But they decided not to do this, I think, because they wanted the restrictions on the object to be explicit (and documented in code), and not as a side-effect of how the Block happens to handle the object.
