• 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: Style Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Style Question


  • Subject: Re: Style Question
  • From: Robert Claeson <email@hidden>
  • Date: Sat, 28 Jun 2008 10:54:39 +0200


On 28 Jun 2008, at 06:30, Alex Wait wrote:

I have noticed, coming from C++ and Visual Studio (at school), a couple
style differences


if (value) {
   //do something
}

insteasd of

if (value)
{
   //do something
}

Also since I am using this style, XCode doesn't tab in for me when I type {
then a return. This is the style I "taught" and I would like to continue the
good habits
during the summer.

I learned C on Unix long before Microsoft had started producing Windows 1.0. The first style was the first style I learned. I believe it's called the K&R style (from the inventors of C) and it also seems to be the preferred style in Java if you look in Sun's Java documentation. When I then learned C++ back in 1988 (from Bjarne Stroustrup, nonetheless), the K&R style was still the style being used.


The first time I came across the latter style was when I had to work on some Windows C and C++ style. I believe the style was more or less invented by Microsoft. Most of the Unix/Linux/Cocoa code I've worked on has used the K&R style.

I personally prefer the K&R style as it is more compact. I can get a better sense of the code on a screenful, while a larger portion of the screen estate is consumed by syntactics (curly braces) that really doesn't add much of a value in the latter style.

But it's mostly a matter of personal preference. Cocoa doesn't care and neither does Xcode. You should be able to set up Xcode to indent properly for you even when using the latter style. If it can't, file a bug report on bugreporter.apple.com.
_______________________________________________


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: Style Question
      • From: Sam Mo <email@hidden>
References: 
 >Style Question (From: "Alex Wait" <email@hidden>)

  • Prev by Date: Re: Core data question in multiwindow doc app
  • Next by Date: DnD for NSBrowser in 10.4
  • Previous by thread: Re: Style Question: apology and correction
  • Next by thread: Re: Style Question
  • Index(es):
    • Date
    • Thread