• 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: Variable declaration in "for" loop initialization expression?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Variable declaration in "for" loop initialization expression?


  • Subject: Re: Variable declaration in "for" loop initialization expression?
  • From: Graham Cox <email@hidden>
  • Date: Thu, 18 Nov 2010 22:52:18 +1100

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

  • Follow-Ups:
    • Re: Variable declaration in "for" loop initialization expression?
      • From: Oleg Krupnov <email@hidden>
References: 
 >Variable declaration in "for" loop initialization expression? (From: Oleg Krupnov <email@hidden>)
 >Re: Variable declaration in "for" loop initialization expression? (From: Graham Cox <email@hidden>)

  • Prev by Date: Re: Variable declaration in "for" loop initialization expression?
  • Next by Date: Re: Variable declaration in "for" loop initialization expression?
  • Previous by thread: Re: Variable declaration in "for" loop initialization expression?
  • Next by thread: Re: Variable declaration in "for" loop initialization expression?
  • Index(es):
    • Date
    • Thread