17 Jan, 2010, Twisol wrote in the 21st comment:
Votes: 0
Barm said:
I prefer Whitesmith's and have always wondered why it's not more popular. It's the easiest to parse visually as the entire block is indented equally in relation to its control statement. Plus, if the goal is to indent logic blocks why treat the 'start of block' and 'end of block' tokens as external elements?


Mainly because having the } back on the previous indentation level helps 'reset' the eye, IMHO.
17 Jan, 2010, David Haley wrote in the 22nd comment:
Votes: 0
For me, if the brace is on the same level as the indented code, it might as well not be present because the indentation change is giving you the same effect. Having a brace on its own, with nothing directly above it, is far easier to spot IMO.
17 Jan, 2010, Davion wrote in the 23rd comment:
Votes: 0
I use kinda a hybrid of the two. Not sure where I picked it up from, but here's an example.

int main( void )
{ std::string str("Hello World!");

if(str.length() > 25 )
{ std::cout << str << std::endl;
return -1;
}
return 24;
}
17 Jan, 2010, elanthis wrote in the 24th comment:
Votes: 0
I just use gotos. No need for braces or indentation. So much easier to write, too.
17 Jan, 2010, Twisol wrote in the 25th comment:
Votes: 0
Sounds like Horstmann, Davion.
17 Jan, 2010, David Haley wrote in the 26th comment:
Votes: 0
elanthis said:
I just use gotos. No need for braces or indentation. So much easier to write, too.

I wuv u guise. :biggrin:
18 Jan, 2010, Sandi wrote in the 27th comment:
Votes: 0
elanthis said:
I just use gotos. No need for braces or indentation. So much easier to write, too.

I have a friend that has apoplexy when I use GOTO. Seriously, though, what's the difference between a goto and a function call? At least with a goto you usually don't have to go back to what you were reading before.
18 Jan, 2010, David Haley wrote in the 28th comment:
Votes: 0
Sandi said:
I have a friend that has apoplexy when I use GOTO. Seriously, though, what's the difference between a goto and a function call? At least with a goto you usually don't have to go back to what you were reading before.

Try recursion, for starters.
There are things to be said about debuggers and logical units of code, as well.
18 Jan, 2010, Scandum wrote in the 29th comment:
Votes: 0
David Haley said:
The main advice I would give is to always use braces even if you have just one line, then there is no issue of remembering or forgetting them.

Seconded. Same story with using your blinkers, routine is your friend.

I use tabs for indentation, (hate it when people mix tabs and spaces), and for spacing I never use tabs, only spaces, so the code looks decent regardless of your tab size setting. There's an argument to be made against spacing, but in some cases it improved readability quite a bit.
18 Jan, 2010, Runter wrote in the 30th comment:
Votes: 0
I write
void meh() { 

}


in C++. Mostly because it is the way we did it at the university I attended. And now because it's what I'm used to.
18 Jan, 2010, elanthis wrote in the 31st comment:
Votes: 0
Quote
Seriously, though, what's the difference between a goto and a function call


Tell me you're being facetious, please.
18 Jan, 2010, Runter wrote in the 32nd comment:
Votes: 0
elanthis said:
Quote
Seriously, though, what's the difference between a goto and a function call


Tell me you're being facetious, please.


Everyone knows goto is better than a function call.

Also, all variables should be global.
18 Jan, 2010, elanthis wrote in the 33rd comment:
Votes: 0
I see what you did there.
18 Jan, 2010, quixadhal wrote in the 34th comment:
Votes: 0
David Haley said:
Sandi said:
I have a friend that has apoplexy when I use GOTO. Seriously, though, what's the difference between a goto and a function call? At least with a goto you usually don't have to go back to what you were reading before.

Try recursion, for starters.


You can do recursion without functions. I did it using BASIC for the TI TRS-80 Mo.... You just have to manage your own state variables, so you can rollback pervious values if need be. CGOTO is a beautiful thing.

You kids and your nerf toys.
18 Jan, 2010, David Haley wrote in the 35th comment:
Votes: 0
Of course you can do recursion with goto statements if you manage your own stack on the side. After all, the function call is doing just that. But the whole point of a proper function call is precisely that you don't have to do all that extra work that's always the same anyway. :wink:
19 Jan, 2010, elanthis wrote in the 36th comment:
Votes: 0
Function calls have return. gotos do not. In fact, right down to the underlying machine codes, many architectures have two separate instructions for goto/branch and call, specifically because the later adds the caller location to the stack and the former does not.

In C/C++, goto also has issues dealing with variable initialization in a safe/easy way.

In general, the only things I would ever use a goto for in a C/C++ app are to break out of heavily nested loops or for error-handling in C (or C++ with exceptions disabled, on platforms like Xbox or PS3 where there is no usable exception support in the compiler toolchain). For general flow-control of logical units, functions are superior, not least of all because they are more readily reusable, and the compiler can do far more intelligent optimizations with functions. Gotos force the compiler into dumb mode because the compiler can't be sure how you're going to jump around the insides of a function, especially when you add support for things like computed gotos.
19 Jan, 2010, Koron wrote in the 37th comment:
Votes: 0
The only time I have ever used goto was when I thought of a new feature I could add to a piece of software I'd written and it was my last day on the job, so I didn't have the time for any semi-serious revision. (And no, it was nothing nefarious.)
20.0/37