Saltar al contenido ForoHackers

Tabs for indentation, spaces for alignment. Fight me.

Revisión de códigoHerramientas de desarrolloCultura hacker
#949 · tabs_over_spaces_42 · · Denunciar

Let me start a war immediately.

My position: tabs for indentation, spaces for alignment. A tab means "one level deeper", and every reader sets their own width. Someone with poor eyesight can use 8, someone who likes dense code can use 2, nobody has to reformat anything.

Spaces for alignment only after the first non-whitespace character:

int total = compute_something(first_argument,
                              second_argument);

Here the continuation lines are aligned with spaces, so the picture stays right at any tab width.

Counterpoint I accept: mixed tabs and spaces done by hand goes wrong in about three days. So I use a formatter and .editorconfig and never think about it again. Which, I admit, is also the actual correct answer to the entire debate.

Spaces people, your move.

#1231 · r3l1c_0f_bbs · · Denunciar

In the BBS days we argued about CP437 versus whatever the sysop's terminal did to box-drawing characters. Compared to that, tabs and spaces is a peaceful garden party.

#1232 · packet_loss_poet · · Denunciar

Go's gofmt made the call for everyone: tabs for indentation, spaces for alignment, no flags, no discussion. Fastest way to end a holy war is to automate the winner.

#1233 · null_terminated_hopes · · Denunciar

I use whatever the file already uses. Consistency beats correctness. The one true indentation does not exist, but a diff that touches every line because someone's editor "helped" certainly does.

Inicia sesión o únete para responder.