This is so clearly right, how can it not yet exist?
‘Just’ dynamic virtual pretty print per personal lang style prefs.
That’s why for function calls passing multiple arguments where each argument may be non trivial, it’s a good idea to put each argument on its own line.
1 /* A function that does something */
2.1 int do_something(int foo,
2.2 int bar,
2.3 int baz)
2.4 {
2.5 return foo + bar + bam;
2.6 }
Which would condense to: 1 /* A function that does something */
2 int do_something(int foo, int bar, int baz) { return foo + bar + bam; }
When you try to compile this, the compiler will complain about line 2, which you know from your editor's line numbering encompasses lines 2.1 through 2.6. As an alternate strategy, you could use column numbers instead of sequential sub-lines, like so: 1 /* A function that does something */
2.0 int do_something(int foo,
2.26 int bar,
2.35 int baz)
2.44 {
2.46 return foo + bar + bam;
2.70 }
And then, if the compiler reports a column number or offset into the line, you'll immediately know "well the compiler's complaining about line 2 column 65, which is between 2.46 and 2.70... golly gee willikers, I fat-fingered the third addend in the return statement!".You could get even more abstract than this, with "line numbers" instead being local to a given scope, and the compiler reporting erroneous line numbers relative to said scope. If the compiler tells you that the syntax error is in the first (in this case also last) statement in the function do_something, then it should be apparent where to look.
That said, I don't know of many text editors (outside of notepad, and even that's gotten better lately) which don't offer options about how to (or not to) wrap text.
So perhaps this is the test of AI, when it formats my code the way I want it all the time without making a mistake.
I think the pragmatic solution is an opinionated linter that can be broken.
A single line of code should be written to file as a single line - no matter how long. However, the editor you are using should be able to gracefully word wrap it depending on your settings.
Most editors word wrap based on window size or some other hard setting. They should be able to wrap gracefully at a logical point in the code e.g. at a comparison operator or a dot in a function chain. Wrapped lines could be tabbed or visually flagged to let you know.
In other words there should not be am ideal line length for code, but instead editors should be able to adapt to make life easier for developers.
Look at word processor documents, imagine how much of a nightmare it would be if such documents had a hard limit of characters per line.