3 ms·
Can't come soon enough. The syntax is a head scratcher. I don't understand why anyone could have possibly thought [[[[]]]] was a good idea! Don't get me started
by matchbok 7y ago
Can't come soon enough. The syntax is a head scratcher. I don't understand why anyone could have possibly thought [[[[]]]] was a good idea! Don't get me started on the closure or variable syntax. Oof.
- favorited 7y agoThe syntax is all about C compatibility. Objective-C (unlike C++) is a strict superset of C. Anything using bracket notation in Objective-C is using dynamic OO message-passing. Anything that reads like C syntax is plain-old C. The closure syntax also relates to C compatibility. Because the Clang blocks extension isn't an extension to Objective-C, but to C. The syntax matches C's function pointer syntax, just replacing the * with ^. ^ was chosen because (A) it has no unary form in C, and (B) it can't be overloaded in C++.
- apple4ever 7y agoI love the brackets. Sure its kind of crazy, but I love how it works.
- jaynetics 7y agoThe brackets do have the advantage that they make the order of evaluation and individual callees totally explicit, unlike some languages with optional parentheses or a mix of dots and other syntax elements. As someone with the unusual distinction of learning to code with ObjC, I found the syntax super helpful as a newbie. Everything looked distinct (e.g. in other languages blocks might only differ from hashmaps by their context), everything was verbose as if explained to a child (Thing *thing = [Thing thingByConvertingOtherThing: otherThing];) and so on.