Re: Variable declaration in "for" loop initialization expression?
Re: Variable declaration in "for" loop initialization expression?
- Subject: Re: Variable declaration in "for" loop initialization expression?
- From: Oleg Krupnov <email@hidden>
- Date: Thu, 18 Nov 2010 13:57:33 +0200
Thanks Graham!
I think I will stick to the more restricted version. It's more compact
and reliable indeed.
It seems that C99 is set by default in XCode. What are the possible
scenarios when I may need to use another dialect?
Oleg.
On Thu, Nov 18, 2010 at 1:52 PM, Graham Cox <email@hidden> wrote:
>
> On 18/11/2010, at 10:47 PM, Graham Cox wrote:
>
>> I don't think there is any significant advantage to either form, except the latter is perhaps a bit more compact in source code. It shouldn't make any difference to the object code.
>
>
> I should also point out that there is a scope difference - in the second form the counter variable only has the scope of the for{...} statement whereas the first form has the scope of the enclosing statement. Arguably the more restricted scoping can help eliminate bugs.
>
> --Graham
>
>
>
_______________________________________________
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