On Jul 4, 2012, at 4:37 PM, Dave wrote: > On 4 Jul 2012, at 07:19, Quincey Morris wrote: > >> On Jul 3, 2012, at 22:40 , Graham Cox wrote: >> >>> NSComparisonResult (^comp)( id<DKStorableObject>, id<DKStorableObject> >>> ) = ^( id<DKStorableObject> a, id<DKStorableObject> b ) >> >> Actually, for a block literal, it's: >> >> … = ^NSComparisonResult ( id<DKStorableObject> a, id<DKStorableObject> >> b ) { … } >> >> The literal syntax puts the return type after the [unparenthesized] "^", >> unlike the pointer syntax which puts the return type before the >> [parenthesized] "^". >> >>> Could the stupid block syntax be any less intuitive? >> >> Well, to be fair, it's *two* stupid syntaxes. >> > > I'm so glad that I'm not the only one that find the Block Syntax the pits. > Myself and a colleague struggled for over an hour trying to get it right and > I'm still no wiser really! > > What I can't understand is why it was implemented that way?!? I mean surely > there could have been a clearer way of defining and executing a block of code > that the one we have at present?
They did it that way because they were following the C function pointer syntax, just replacing the * with a ^. Really, the blame for this lies with Kernighan and Ritchie more than anyone else. I think Apple followed the C syntax because they may have some hopes about getting blocks officially added to some future revision of the C specification, although I’m not sure how realistic that is. Charles _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com