5 ms·
Unless I'm missing something it doesn't solve the main issue with tabs vs. space which is that most people and editors don't do it right, that is indent with ta
by simias 8y ago
Unless I'm missing something it doesn't solve the main issue with tabs vs. space which is that most people and editors don't do it right, that is indent with tabs and align with spaces. How does Elastic TabStops deal with that? For instance in code like:
int main() {
printf("%s, %s, %d",
somevariable,
somefunction(),
42);
}
Because beyond that I personally (and very subjectively) consider that adding comments on the same line as the code is usually a bad idea when you can put them on the previous line and it's both better suited to long comments and easier to match the comment with the line. In the example from the gif in the article consider the distance between the `x();` code and the matching comment all the way to the right. Putting it on the line before would make more sense IMO. Most decent code editors will also be able to wrap the comment more easily that way. That being said I'm anal about enforcing 80 columns in my code so maybe I'm just a weirdo.
- GuB-42 8y agoThe idea seems to be: add a tab between printf( and "%s in order to get a result that looks like your example. Elastic tabstops are great for making table like code, not just for aligning comments. But for me, the cons outweighs the pros. The biggest problem is that it requires a specific interpretation of the tab character that is uncommon and nonstandard.
- simias 8y agoOh that's quite clever actually. But I agree, overall it seems like an interesting idea but it's not good enough to warrant modifying and/or replacing all existing tools who deal with displaying and editing code.
- vbezhenar 8y agoYou'll have ⇥printf(⇥"%s, %s, %d", ⇥ ⇥somevariable, ⇥ ⇥somefunction(), ⇥ ⇥42); Doesn't look very pretty and wastes one space.
- nerdponx 8y agoSince the tabs are semantic and not visual, you could easily have the first tab rendered as zero-width.
- taeric 8y agoSince elastic tabstops are basically the way TeX lets you define tabs, yes, you could do what you want. Even with variable width fonts. :)
- kuon 8y agoIf I cannot fit a function call on one line, I usually prefer this indent: int main() { printf( "%s, %s, %d", somevariable, somefunction(), 42 ); }
- guitarbill 8y agoWhy not always do this? Once you stop using column alignment/align with opening delimiter, and use hanging indent, these issues go away: int someLongFunctionNameThatWillBeRefactored(int foo, int bar); someLongFunctionNameThatWillBeRefactored(longVariableName1, longVariableName2); and do int someLongFunctionNameThatWillBeRefactored( int foo, int bar); someLongFunctionNameThatWillBeRefactored( longVariableName1, longVariableName2); or even int someLongFunctionNameThatWillBeRefactored( int foo, int bar); Now tabs work fine. Spaces work fine. Elastic TabStops? Ironic that he mentions "Keep it simple, stupid!" and then overengineers this thing and every editor along the way. Anyway, this will probably not go down well since everybody has been trained to use the former style, and now people "prefer" it, out of what seems to me to be habit.
- simias 8y agoI don't think scare quotes are warranted, I do prefer the former style, I find that it makes it easier to match the arguments to the function at a glance. Of course it's purely subjective. I do note that even your proposition doesn't really solve the problem of using Elastic TabStops, because if you imagine a comment spanning all three lines: someLongFunctionCall(⇥ /* This function call */ ⇥ longVariableName1,⇥ /* is really cool * ⇥ longVariableName2);⇥ /* and stuff */ You have an additional tab at the beginning of the two last lines which means (as far as I understand it) that the first comment line won't necessarily line up with the two others. Of course that showcases a potential issue with Elastic TabStops, not your particular coding style.
- guitarbill 8y ago
- Ajedi32 8y agoThe first GIF in the article clearly shows how that case would be handled: http://nickgravgaard.com/elastic-tabstops/images/columnblocks_coloured.gif http://nickgravgaard.com/elastic-tabstops/images/columnblock... The red section in that GIF is analogous to your example.