Re: NS_INLINE and obj = nil;?
Re: NS_INLINE and obj = nil;?
- Subject: Re: NS_INLINE and obj = nil;?
- From: Alexander Spohr <email@hidden>
- Date: Sat, 2 Jan 2010 18:30:13 +0100
Am 02.01.2010 um 17:28 schrieb Clark Cox:
> On Sat, Jan 2, 2010 at 6:29 AM, Alexander Spohr <email@hidden> wrote:
>> Would this not work as well:
>> #define GDRelease(x) { [(x) release]; (x) = nil; }
>>
>> Or even this:
>> #define GDRelease(x) [(x) release], (x) = nil;
> No, neither would work as well. Consider the following:
>
> if(x)
> GDRelease(x);
> else
> foo(x);
>
>
> With the do/while, that expands to:
>
> if(x)
> do { [(x) release]; (x) = nil; } while (0);
> else
> foo(x);
>
> which works just fine.
I see.
> However, your first example, would expand to:
>
> if(x)
> { [(x) release]; (x) = nil; };
> else
> foo(x);
>
> That semi-colon makes that statement a parse error.
Right.
> and your second example expands to:
>
> if(x)
> [(x) release]; (x) = nil;
> else
> foo(x);
>
> which is also a parse error.
No to this.
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.
atze
_______________________________________________
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