• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: inference of block return type
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: inference of block return type


  • Subject: Re: inference of block return type
  • From: Bill Bumgarner <email@hidden>
  • Date: Mon, 28 Jun 2010 15:38:18 -0700

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 (email@hidden)

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:

This email sent to email@hidden

References: 
 >inference of block return type (From: Matt Neuburg <email@hidden>)
 >Re: inference of block return type (From: Tony Romano <email@hidden>)
 >Re: inference of block return type (From: Michael Ash <email@hidden>)
 >Re: inference of block return type (From: Bill Bumgarner <email@hidden>)
 >Re: inference of block return type (From: Michael Ash <email@hidden>)
 >Re: inference of block return type (From: Tony Romano <email@hidden>)
 >Re: inference of block return type (From: Bill Bumgarner <email@hidden>)
 >Re: inference of block return type (From: Dave DeLong <email@hidden>)

  • Prev by Date: Re: inference of block return type
  • Next by Date: Re: using UTF-32 in NSString.
  • Previous by thread: Re: inference of block return type
  • Next by thread: Re: inference of block return type
  • Index(es):
    • Date
    • Thread