8 ms·
Or better, we should save source code files replacing tabs with spaces. That's the best practice that makes everybody happy.
by tuxone 12y ago
Or better, we should save source code files replacing tabs with spaces. That's the best practice that makes everybody happy.
- custardcream 12y agoGo uses tabs. That's the law. It's in the documentation. Groups of spaces and tabs are semantically different. Tabs mean indentation. Spaces mean spaces.
- tuxone 12y agoMy apologies, thank you for the clarification.
- treehau5 12y ago>Tabs mean indentation. Sorry but this is false. The only thing a tab means, is tab. Please provide your reasoning for the down voting. Thank you.
- custardcream 12y agoThe dictionary in front of me disagrees: "A key on a computer keyboard that, when pressed, inserts a special ASCII character used for formatting text, as in indenting a line or block of text." Actually going back it means tabulation which was an early form of alignment of tables on typewriters. The tab key advanced the carriage to the next tabulation point. It was repurposed as a way of indenting code later and it has become an additional definition of that fact. (I'm old enough to have owned a typewriter, a nice Selectric one as well ;-)
- treehau5 12y agoWe are talking about computer semantics which exist in a discretized world, not english language semantics. By your logic, the word integer would be any number not a fraction or decimal down to negative infinity up unto positive infinity. There is no concept of infinity on a computer. Anyways, that's besides the point, and I think you missed the meaning behind my comment. The reason why a tab space cannot semantically mean indentation in our world, is because nobody can agree on what that indentation should be. Since you are old enough to have owned a typewriter, maybe you are old enough to remember that by legacy, a tab was equivalent to exactly 8 spaces, and much of our software that runs the internet makes that assumption. Now however, people are saying "use tab to mean indent and everyone can have their way" To quote mikko, "There is no style guide or coding conventions saying that the tab character should be the indent. This assumption is easy to make because it allows you to stick your head into the sand, ignore the surrounding world and by singing “let the users pick their own tab width” mantra." Again, this wasn't to start a tab vs spaces war for go, and why go chose tabs. It's fine to make a choice, but it was your second statement that provoked my comment.
- custardcream 12y agoI get what you mean but a tab is purposely meaningless and unqualified. It means 1 indent, not 8 spaces, 3 bananas or one tree. It is a unit. How the user displays that is up to them.
- trebor 12y agoThis. Absolutely this. I used to hate tabs and want 2 spaces only, until I started working with other developers. Then suddenly tabs made sense, especially when you've got IDEs coercing every edited file to a person's indentation standard. Standardize on the tab and the pain goes away.
- munificent 12y ago> There is no concept of infinity on a computer. Sure there is: http://en.wikipedia.org/wiki/IEEE_754-1985#Positive_and_negative_infinity http://en.wikipedia.org/wiki/IEEE_754-1985#Positive_and_nega...
- treehau5 12y agoOk sorry. There is no true representation of infinity.
- stickfigure 12y ago...or Scotsmen.
- aric 12y agoSemantics is contingent upon meaning. Meaning varies and changes. Meaning is defined over time. That's the case with most words. In formatting text, it's as semantic to say that tabs are for "tabulation" and "indentation" as much as spaces are for "space" and "spacing characters." Tabs have always been semantically better as indentation in computing.
- Artemis2 12y agoSpaces are tolerated, but the usage of tabs is very encouraged.
- deleted 12y ago[deleted]
- halostatue 12y agoThe Go team has made the decision that the language supports tabs for indentation, and it’s enforced by `go fmt`.
- andrewprock 12y agoWhile this is clearly the wrong decision, one has to applaud the Go team for building `go fmt` and thus putting and end to unproductive discussions about formatting. (Although it would have been nice if `go fmt` didn't change code semantics.)
- couchand 12y agoI'm relatively new to Go, and like you I wholeheartedly agree with the idea of solving formatting once and being done with it (and as an aside, I agree that tabs are the wrong decision). It was my impression that gofmt was essentially a pretty printer. Can you point to examples where it changes semantics?
- andrewprock 12y agogo fmt will reorder your imports, which means that if there is an import ordering dependency, it will either be exposed (or hidden) by go fmt.
- ominous_prime 12y agoyou should never have an import order dependency, since initialization order is unspecified.
- andrewprock 12y agoShoulda woulda coulda: https://bugs.launchpad.net/gocheck/+bug/1178806 https://bugs.launchpad.net/gocheck/+bug/1178806
- 12y ago
- _ak 12y agoWhy? n spaces encode a specific preference for indentation, while tabs just represent a level of indentation. How many columns these actually are is entirely up to personal preference and editor configuration. That's why tabs are always superior for indentation.
- andrewprock 12y agoIt's actually quite a bit more subtle than that. Even `go fmt` uses tabs to format indentation, but uses spaces to format alignment. This is distinct from mechanical typewriters which used variably sized tab-stops to handle tab alignment.