On Jun 28, 2008, at 6:39 AM, Sam Mo wrote:

On Jun 28, 2008, at 4:54 AM, Robert Claeson wrote:

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 got the impression that the latter style was rooted from Pascal (or even Algo) programmers where they usually place the "begin" and "end" on separate lines.


If you look at an example BCPL program, you'll see the block style is similar to the second example above, except the closing curly brace is on the same line as the last line of the block - the mirror image of the first example

You can d/l the BCPL reference manual that contains an example program here:

http://www.fh-jena.de/~kleine/history/languages/Richards-BCPL- ReferenceManual.pdf

(This manual is actually from a TYPEWRITER )

The example starts on page 29. BCPL is using $( and $) as the equivalent of { and }

BCPL is the ancestor of B which is the ancestor of C, so this style predates C.




_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to