On Jun 28, 2010, at 3:20 PM, Dave DeLong wrote:

> Except that the Short Practical Guide to Blocks you linked to uses:
> 
> <return type> ^ (<arg-list>) { <code> };

That is a typedef form, not the block literal form.

Wee fun.

    BOOL (^blocksOfFun)(int) = ^ BOOL (int x) {
        return x % 3;
    };
    
    for(int i=0; i<10; i++)
        NSLog(@"Is fun? %@", blocksOfFun(i) ? @"YES": @"NO");

2010-06-28 15:36:12.989 dfjkdfjk[4852:307] Is fun? NO
2010-06-28 15:36:12.991 dfjkdfjk[4852:307] Is fun? YES
2010-06-28 15:36:12.991 dfjkdfjk[4852:307] Is fun? YES
2010-06-28 15:36:12.992 dfjkdfjk[4852:307] Is fun? NO
2010-06-28 15:36:12.993 dfjkdfjk[4852:307] Is fun? YES
2010-06-28 15:36:12.993 dfjkdfjk[4852:307] Is fun? YES
2010-06-28 15:36:12.994 dfjkdfjk[4852:307] Is fun? NO
2010-06-28 15:36:12.994 dfjkdfjk[4852:307] Is fun? YES
2010-06-28 15:36:12.995 dfjkdfjk[4852:307] Is fun? YES
2010-06-28 15:36:12.995 dfjkdfjk[4852:307] Is fun? NO

The underlying issue being that the C language's syntax -- as defined by 
standard syntax -- is drawer full of knives, some without handles.   Layer on 
the C++ standard [Objective-C++] and some of 'em have blades on both ends that 
are rusty.

That is to say that the function declaration comparison for blocks only applies 
to typedefs because there is no inline named function form akin to a block 
literal.

b.bum

_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to