6 ms·
Name a few please. I can only think of garbled alignment when reading a diff of a file which used tabs to indent. And that is not really speaking for tabs.
by mlang23 5y ago
Name a few please. I can only think of garbled alignment when reading a diff of a file which used tabs to indent. And that is not really speaking for tabs.
- DocTomoe 5y ago- semantic coherency: use only one character to signify an indentation level - user preference of UI representation of code: decide for yourself how far a tab indents a codeblock. - less reformatting necessary during refactoring and rewriting - separation of keyboard keys for different functionality Just the first few that come to mind.
- hnedeotes 5y agoWell, the most basic one is that if I prefer that my code blocks indent on 4 visual "spaces", but you prefer that it does on 2, there's no way of representing that with spaces. Tab means, 1 indentation level. How you choose to display that is then a matter of personal preference. So you can have your cake and eat it too. Then if I or someone else needs to de-ident a line you remove 1 char. Plus, if your IDE&mode is worth its salt, hitting tab on an already indented line doesn't do anything, and because it has a simple meaning, hitting tab on a non indented line simply indents it. Of course, if people mix tabs and spaces without understanding them it will be garbled. Or if people just want the cake for themselves, greedy spacers!
- jcelerier 5y agoThat does not work in practice. Consider void foo() { connect(this, action, that, callback); } If the "that, callback);" line was indented with tabs, then any other tab length would make it go at any random place. Thus if you just use tabs your code is only readable with the tab length used for writing it. So instead you can introduce spaces for alignment ; now that you have spaces needed for alignment, why not just use spaces for everything instead of two characters ??
- eMSF 5y agoSo that anyone viewing the code can choose the indentation width according to their own preference? It really can't be that hard to grasp... It can still be argued that it's not worth the trouble, especially with the poor tooling available, but what I can't really understand is how supposedly smart people turn off their inner logic when it comes to such a simple concept.
- jcelerier 5y ago> So that anyone viewing the code can choose the indentation width according to their own preference? It really can't be that hard to grasp... but viewing that code with anything other than the tab length it was written for breaks it ! here are some screenshots: - I wrote the code with ts=4 and it looks as it must look: https://imgur.com/Bgr6Pvl https://imgur.com/Bgr6Pvl - if your editor is configured for two spaces tabs ? broken ! https://imgur.com/oxj2If7 https://imgur.com/oxj2If7 - if your editor is configured for eight spaces tabs ? broken ! https://imgur.com/puCqdL8 https://imgur.com/puCqdL8
- eMSF 5y agoWhy are you writing this to me? You already commented on (another) comment of mine which explained what is meant by indentation with tabs and alignment with spaces. A function call has an indentation level (depending on where it resides in the code); if for whatever reason you split the call on multiple lines, all the lines should have an equal amount of leading tabs to signal that level of indentation – different arguments in a function call do not have different indentation levels. If you choose to align the contents on the lines, for example to the opening parenthesis, you do so by using spaces. In your own words, this is "all those shenanigans" but you can't possibly try to convince me it is that hard to understand or would not work. Of course it does.
- jcelerier 5y ago> Why are you writing this to me? I just reply to the comment text > what is meant by indentation with tabs and alignment with spaces. but I said at the beginning that this was not good: > So instead you can introduce spaces for alignment ; now that you have spaces needed for alignment, why not just use spaces for everything instead of two characters ?? In my experience, allowing both tabs and spaces just leads to that kind of mess, consistently: https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/std/any?ts https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-... and for zero good reason as alignment is a semantic thing, and tools cannot understand the semantics of your code (at a human level, not a "pl semantic" level)
- FriedrichN 5y ago> garbled alignment when reading a diff of a file which used tabs to indent I have never experienced this. Tabs are of consistent length, so how can the indentation be garbled?
- Aaargh20318 5y agoTabs are not of consistent length. A tab does not insert X spaces worth of whitespace. A tab moves the cursor to the next tab-stop. There can still be alignment issues if different people choose different tab-stop intervals.
- FriedrichN 5y agoThat's why tabs are used for indentation and not alignment. From col 0 on tabs are consistent.
- CannisterFlux 5y agoThe only case I can think of is when the patch has lines above or below indented with spaces and a modified line with tabs. It looks OK in an editor, but the extra +/-/space from the diff doesn't move the tabbed code, which still is indented to the tab-stop boundary (the tab "absorbs" the diff marker). The space-indented lines are moved 1 to the right by the diff marker, but the code on the tab line now looks to be 1 character too far to the left in the diff. The problem is not the tabs, instead it stems from trying to mix lines indented with tabs and lines indented with spaces.
- Zarel 5y agoSo I don't agree with GP poster that there's no reason to use spaces for indentation, but Rome recently switched to using tabs for accessibility reasons: https://github.com/rome/tools/issues/425 https://github.com/rome/tools/issues/425 (Especially look at the Reddit thread linked from that issue: https://www.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/ https://www.reddit.com/r/javascript/comments/c8drjo/nobody_t... ) (The problem is that people with visual impairment disabilities benefit a lot from being able to customize tab widths.)