Block Syntax is Ridiculous

I love blocks and hate block syntax. It seems so arbitrary!

Consider literal Blocks

^returnType(Type param1, Type Param2) {

Vs. Block Variable Definitions

returnType(^variableName)(Type, Type)

Vs. Block Parameter Definitions


What’s going on with the ^ operator, which lives outside parentheses in a block literal but inside in a block parameter?

Why does the parameter name go at the end of the block type declaration, while the variable name goes right in the middle of the type declaration–unlike every other C variable you’ve defined?

Update, as Peter Hosey helpfully pointed out:

And WHY does the return type go outside the ^ in a parameter and variable definition but inside the ^ in a block literal?

It’s like Apple did everything in their power to make sure it was inconsistent. I’m almost surprised that the parameter list isn’t nil terminated when you pass in parameters, but maybe they didn’t think of that.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s