Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,543,529
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 05-06-24 02:06 AM
Guest: Register | Login

0 users currently in Computing | 1 guest

Main - Computing - Programming Poll #5: { } New thread | New reply

Pages: 1 2

GuyPerfect
Posted on 03-16-07 05:43 AM Link | Quote | ID: 15657


Paratroopa
Level: 30

Posts: 3/155
EXP: 152717
Next: 13152

Since: 03-14-07

Last post: 6055 days
Last view: 6004 days
{ and }, in the world of programming documentation, are quite commonly referred to as "Curly Braces," while I just personally call them "Braces." The < and >, FYIngly enough, are "comparison brackets."

When using languages with braces, I do the good ol':

int main(int argc, char **argv) {
if (argc == 1) {
printf("\nHey, man. Give an argument, man.\n");
return 1;
} else if (argc > 2) {
printf("\nHoly cow, not that many!\n");
return 2;
}

printf("\nYour argument is %s!\n", argv[1]);
return 0;
}

I don't see a real need to put the brace on the next line. I mean, if you have more than one statement, you need a brace, and I always indent under such circumstances. To me, the first line in the block introduces the indentation, and the closing brace signals its end.

If there is only one statement within the block, I will rarely, if ever (never happened yet) include the braces. Depending on the length of the line, however, I have been known to newline and intent as if there were braces. Example:

if (ThingImTestingFor == 2)
Jeez(ThisIs, AVery, Freaking, LongLine, Sorta, NotReally);

Cellar Dweller
Posted on 03-16-07 06:44 AM Link | Quote | ID: 15664


Snifit
Level: 39

Posts: 14/287
EXP: 385482
Next: 19289

Since: 02-19-07
From: Arkansas

Last post: 4061 days
Last view: 3229 days
1. Curly braces, as others have stated.

2. My code is 1TBS compliant.

3. I generally use braces even if one one line is in the block. This is a habit that solidified during my brief experience with Perl, in which the braces are manditory.

If anyone wants to see some of my code, I have already posted a code sample in another thread.

Posted by Kernal
So, to you people who use K&R style, why don't you also put the closing curly bracket at the end of the last line of the block?


In my case, I don't line up brace to brace, I line up the ending brace to the control construct that precedes the block of code.
Pages: 1 2


Main - Computing - Programming Poll #5: { } New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.020 seconds. (322KB of memory used)
MySQL - queries: 42, rows: 52/53, time: 0.017 seconds.