Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

the problem i encounter is when you try to break a long line into multiple lines. if you want to use tabs and align the continuation, you should be mixing spaces and tabs.

for example ('-' is tab, '.' is space):

    --function_with_lots_of_arguments(arg1, arg2, arg3,
    --................................arg4, arg5, arg6);
it can be done, but a lot of editors get it wrong and it requires paying attention to the whitespace.

of course, another style would be to just indent the continuation twice, without aligning it. (i personally prefer to align continuations.)



Some food for thought: https://youtu.be/ZsHMHukIlJY?t=633

For example, this is the best way to define functions with argument lists long enough not to fit on a single line:

  fn doThing(
      argument1,
      argument2,
      argument3,
  ) {
      <code>
  }
Visually clear, doesn't have any spaces/tabs issues, produces minimal diffs when adding/removing/renaming arguments.


Very interesting talk! Thanks for the reference.

More food for thought:

The style in your example is more consistent with the way nearly every programmer formats code that has more than one statement. For example:

  if( shouldDoThings ) {
      doOneThing();
      doAnotherThing();
      doLastThing();
  }
Why do we want to format statements that way, but function calls and expressions a different way? No one would write this:

  if (shouldDoThings) {doOneThing();
                       doAnotherThing();
                       doLastThing();}
I have a theory about that but will have to save it for another day.

Somewhat related, the Rust coding style guidelines used to follow a heavily column-aligned style, but changed to indentation-only a year or two ago. I posted an example from the Servo source code with the old and new formats here:

https://news.ycombinator.com/item?id=18962177




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: