• 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: NS_INLINE and obj = nil;?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NS_INLINE and obj = nil;?


  • Subject: Re: NS_INLINE and obj = nil;?
  • From: Greg Parker <email@hidden>
  • Date: Sun, 3 Jan 2010 08:28:46 -0800

On Jan 2, 2010, at 9:30 AM, Alexander Spohr wrote:
> I put a , not a ; between the statements. So at least my last example would work - had I just left the last ; out of it:
>
> #define GDRelease(x) [(x) release], (x) = nil
> expands to:
> if(x)
>   [(x) release], (x) = nil;
> else
>   foo(x);
>
> But the while(0) looks not as fragile.

The do..while form also prevents errors like this:

    if (GDRelease(x))  { ... }
    // this is nonsense

    if ( do { [(x) release]; (x) = nil; } while (0) ) { ... }
    // this expansion is a compile error: good

    if ( [(x) release], (x) = nil ) { ... }
    // but this expansion compiles successfully: bad


--
Greg Parker     email@hidden     Runtime Wrangler


_______________________________________________

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

  • Follow-Ups:
    • Re: NS_INLINE and obj = nil;?
      • From: Dave G <email@hidden>
References: 
 >NS_INLINE and obj = nil;? (From: aaron smith <email@hidden>)
 >Re: NS_INLINE and obj = nil;? (From: "Stephen J. Butler" <email@hidden>)
 >Re: NS_INLINE and obj = nil;? (From: Alexander Spohr <email@hidden>)
 >Re: NS_INLINE and obj = nil;? (From: Clark Cox <email@hidden>)
 >Re: NS_INLINE and obj = nil;? (From: Alexander Spohr <email@hidden>)

  • Prev by Date: Re: Drawing on top of QTCaptureView
  • Next by Date: Re: Drawing on top of QTCaptureView
  • Previous by thread: Re: NS_INLINE and obj = nil;?
  • Next by thread: Re: NS_INLINE and obj = nil;?
  • Index(es):
    • Date
    • Thread