|
Indentation (4 spaces vs 8 spaces) |
Matthew Leverton
Supreme Loser
January 1999
|
I prefer: void output(ostream &out) { for(int i = 0; i < 24; i++) if(i%24) for(int j = 0; j < i; j++) out << i * j << endl; }
|
bamccaig
Member #7,536
July 2006
|
I prefer: } ;ldne << j * i << tuo )++j ;i < j ;0 = j tni(rof )42%i(fi )++i ;42 < i ;0 = i tni(rof { )tuo& maertso(tuptuo The compiler hates me. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
Neil Black
Member #7,867
October 2006
|
public static void main(String args[]){ System.out.println("Hello World"); } My style of choice is a bit unorthodox.
|
CGamesPlay
Member #2,559
July 2002
|
int _main_loop_ = _tick<_while<_not<keys<KEY_ESC> >,_compound<_while<_gt<timer, _const<0> >,_compound< dec_timer,_compound<_compound<_compound<_if<_and<keys<p1_up>, _gt<_get<p1>, _get<top> > >, _addeq<p1, _neg<_const<1> > >, _if<_and<keys<p1_dn>, _lt<_add<_get<p1>, _const<paddle_h> >, _get<bottom> > >, _addeq<p1, _const<1> >, _nil> >, _if<_and<keys<p2_up>, _gt<_get<p2>, _get<top> > >, _addeq<p2, _neg<_const<1> > >, _if<_and<keys<p2_dn>, _lt<_add<_get<p2>, _const<paddle_h> >, _get<bottom> > >, _addeq<p2, _const<1> >, _nil> > >, _compound<_compound< _addeq<bx, _get<bxv> >, _addeq<by, _get<byv> > >, _if<_lt<_get<by>, _get<top> >, _compound<_set<by, _get<top> >, _set<byv, _const<1> > >, _if<_gt<_get<by>, _get<bottom> >, _compound<_set<by, _add<_get<bottom>, _const<-1> > >, _set<byv, _const<-1> > >, _nil> > > >, _compound<_if<_and<_lt<_get<bx>, _add<_add<_get<left>, _const<paddle_w> >, _const<ball_r> > >, _and<_not<_lt<_get<by>, _get<p1> > >, _not<_gt<_get<by>, _add<_get<p1>, _const<paddle_h> > > > > >, _set<bxv, _const<1> >, _if<_and<_gt<_get<bx>, _add<_add<_get<right>, _const<-paddle_w> >, _const<-ball_r> > >, _and<_not<_lt<_get<by>, _get<p2> > >, _not<_gt<_get<by>, _add<_get<p2>, _const<paddle_h> > > > > >, _set<bxv, _const<-1> >, _nil> >, _if<_lt<_get<bx>, _get<left> >, _compound<_compound<_set<bx, _const<paddle_w> >, _set<by, _add<_get<p1>, _const<paddle_h / 2> > > >, _compound<_set<bxv, _const<1> >, _addeq<s2, _const<1> > > >, _if<_gt<_get<bx>, _get<right> >, _compound<_compound<_set<bx, _add<_get<right>, _const<-paddle_w> > >, _set<by, _add<_get<p2>, _const<paddle_h / 2> > > >, _compound<_set<bxv, _const<-1> >, _addeq<s1, _const<1> > > >, _nil > > > > > >, _compound<_compound<draw<score<_get<s1>, _get<s2> > >, draw<ball<_get<bx>, _get<by> > > >, _compound<_compound<draw<paddle<_get<left>, _get<p1> > >, draw<paddle<_add<_get<right>, _neg<_const<paddle_w> > >, _get<p2> > > >, draw<flip> > > > > >(); // This line is 1984 characters long at this dot. -- Ryan Patterson - <http://cgamesplay.com/> |
BAF
Member #2,981
December 2002
|
How did I know that was coming! |
ReyBrujo
Moderator
January 2001
|
Yeah -- |
OICW
Member #4,069
November 2003
|
Quote: How did I know that was coming! Maybe because it was here before and this is a.cc? [My website][CppReference][Pixelate][Allegators worldwide][Who's online] |
Trezker
Member #1,739
December 2001
|
Comments go before the code it describes, not on the same line. |
CGamesPlay
Member #2,559
July 2002
|
Oh, since this thread is still around, I want to highlight the experience I had with Dev-Cpp the other day. I needed to use that because it was the best available source code editor on a particular system.
In other words, Dev-Cpp indents with 8-width tabs plus spaces a number of times equal to the index of the first space character in the previous line plus one If you try to remove the idiotic scheme it's got, you can backspace to where you need to be and then hit tab to automatically reapply the idiotic indentation scheme -- Ryan Patterson - <http://cgamesplay.com/> |
ImLeftFooted
Member #3,935
October 2003
|
Yeah it sucks but there's a setting for it. The one thing Dev-Cpp is really missing is highlighting multiple lines and hitting tab or shift-tab. |
BAF
Member #2,981
December 2002
|
X-Code does that too. I lose a whole block of code, and have to hit undo, and the whole time I'm thinking to myself "why would I ever want to replace a whole block of code with a tab?" |
Karadoc ~~
Member #2,749
September 2002
|
I use 4 spaces (not tab, spaces; is that "hard" or "soft" spaces?). When I'm posting code on a.cc I use just 2 spaces. I prefer to use spaces rather than tabs because they are more predictable. A space is always just a space on any computer in any (sane) editor, but tabs vary in size. (Disclaimer: I'm not trying to say that spaces are better than tabs or anything like that. I know there are many good reasons for using tabs. I'm just giving the main reason for my preference.) ----------- |
CGamesPlay
Member #2,559
July 2002
|
Quote: A space is always just a space on any computer in any (sane) editor, but tabs vary in size. A tab is always a tab: exactly how big I want it to be, regardless of whose code I'm reading. -- Ryan Patterson - <http://cgamesplay.com/> |
Karadoc ~~
Member #2,749
September 2002
|
CGamesPlay said: A tab is always a tab: exactly how big I want it to be, regardless of whose code I'm reading. Wow. I'd never thought of that before. I'm completely converted! ----------- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Quote: A tab is always a tab: exactly how big I want it to be, If your editor supports resizing tabs, and if you don't mind having to change your tab size setting every time you want to read someone else's code, invariably due to 'tab + space' indentation. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
CGamesPlay
Member #2,559
July 2002
|
Quote: If your editor supports resizing tabs, and if you don't mind having to change your tab size setting every time you want to read someone else's code, invariably due to 'tab + space' indentation. The only place that happens is in legacy Allegro source code, which was 3 space indentation with 8-space tabs used when possible. Seriously wtf. Anyways, what you're saying is a lie. Anybody whose code I've read is tab indentation with space alignment and it works properly, every time. -- Ryan Patterson - <http://cgamesplay.com/> |
OnlineCop
Member #7,919
October 2006
|
Edgar Reynaldo said: If your editor supports resizing tabs, and if you don't mind having to change your tab size setting every time you want to read someone else's code, invariably due to 'tab + space' indentation. Which wouldn't be a problem if everyone used tabs to indent, and spaces to align... Some a.cc programmers here set their tabs to be equivalent to a single space, others to 8. As long as comments are indented with tabs to the same level as the lines before/after, and then spaces to align everything, there'd be no difference in different IDEs rendering the code (except for how far horizontally you have to scroll to see too-long lines). Of course, with monitors being wider than they are tall in most setups, word wrap set to 80 characters is outdated for most except terminal connections.
|
MiquelFire
Member #3,110
January 2003
|
Assuming the person used tab for indentation only, and no alignment what so ever. (That is, there's no place that is 8 (or whatever the editor is set to) spaces long that got replaced with a tab by the editor. --- |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Quote: Anyways, what you're saying is a lie. Anybody whose code I've read is tab indentation with space alignment and it works properly, every time. I said 'tab + space' indentation, not alignment. There was no lie, you're incorrect. Quote: The only place that happens is in legacy Allegro source code, which was 3 space indentation with 8-space tabs used when possible. Seriously wtf. Which is a decent percentage of the current A4 code. Ctrl-R for the win. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
SiegeLord
Member #7,827
October 2006
|
Quote: Ctrl-R for the win AStyle for the win, since it also fixed the incorrect bracket styles as well as doing proper indentation. "For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18 |
Matthew Leverton
Supreme Loser
January 1999
|
The Allegro problem is because of the three space rule. Most Windows IDEs automatically impose a tab indentation style because that's what the advanced world uses. I've still never yet seen a useful argument why somebody would want to press a key three or four or eight times when you can just press tab once. Why impose your tab size on other people? Working on the Allegro codebase with space indentation makes me angry inside. And the terrible mix of tabs and spaces I accidentally commit makes the space-aholics angry inside. The other thing that makes me angry inside is opening curly braces at the end of the line. I'll never get used to doing that when working on Allegro code. And that makes the unaligned-curly-aholics angry inside. |
Edgar Reynaldo
Major Reynaldo
May 2007
|
Quote: I've still never yet seen a useful argument why somebody would want to press a key three or four or eight times when you can just press tab once. Ah, but pressing tab once in Code Blocks lets you put a set number of spaces down in it's place if you wish it to. Which is infinitely preferable to seeing all those flipping tab arrows. Yes, you can turn off the tab arrow display as SiegeLord pointed out to me, but then you don't get to see the dotted space indicators. Get the Code Blocks guys to implement the option to display tabs as a set of dotted spaces, and I'll quit being annoyed at all the !@#$%@# tabs. My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
Matthew Leverton
Supreme Loser
January 1999
|
Whitespace should be invisible. |
OnlineCop
Member #7,919
October 2006
|
There should be a language where whitespace is replaced by punctuation. Tabs are actually #s and spaces are actually .s. #if.(.whitespace_is_bad.).{ ##return.waffle; #}.else.{ ##return.crouton; #} #//This.is.a.comment.where.anything,.including spaces is.allowed! #//And,.this.is.properly.indented.and.aligned!
|
bamccaig
Member #7,536
July 2006
|
Notepad++ lets you view all characters. It's kind of fun to see whitespace. At the same time, I think it could get in the way during real work... I usually have that feature disabled. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|
|