Page 1 of 1
Code Indentation: Tabs Versus Spaces
Posted: June 18th, 2017, 5:57 pm
by Norbert
Well, I created this document.
Code_Indentation_Tabs_Versus_Spaces.pdf
Took me longer to write than I expected, but I like the result.
Re: Code Indentation: Tabs Versus Spaces
Posted: June 24th, 2017, 12:45 pm
by David
Interesting.
Are you planning similar documents about other aspects of coding style?
Btw, in the list of "programming languages that use whitespace to determine functionality" (last page), you should add Python.
I looked through the SDLPoP sources.
Indentation is mostly done using tabs, but there are a few places that use spaces.
I guess I should fix that.
Btw, the forum does something odd with tabs:
Each tab becomes 3 spaces.
Not a tab-stop at every third character position, but always 3 spaces.
Re: Code Indentation: Tabs Versus Spaces
Posted: June 24th, 2017, 5:29 pm
by Norbert
David wrote:Are you planning similar documents about other aspects of coding style?
No, life's too short.
David wrote:Btw, the forum does something odd with tabs:
Each tab becomes 3 spaces.
Not a tab-stop at every third character position, but always 3 spaces.
Not odd. Fixed tab stops are not (yet widely) used on the web. The tab-size CSS property, which does not yet work on mobile phones, also only specifies the "number of spaces in a tab" (
source). So, "always [n] spaces" is their only option. (Regardless, they should just leave tabs alone.) Also, what you did will never work anyway. You used hard tabs for (mid-line) alignment. From the software's perspective, what you posted could've come from anywhere. Tab stop widths vary. What you posted only looks correct with tab stop width 4 and up. Paste it in an editor and set the tab stop to 2 or 3; you'll see your formatting breaks.
Re: Code Indentation: Tabs Versus Spaces
Posted: June 26th, 2017, 6:44 pm
by David
Norbert wrote:Also, what you did will never work anyway. You used hard tabs for (mid-line) alignment.
Ah, yes. So I inadvertently posted another argument against using tabs for alignment.