Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Indent continuation lines with 2 indentations #2766

Merged
merged 1 commit into from
Jan 28, 2021

Conversation

belka-ew
Copy link
Contributor

@belka-ew belka-ew commented Mar 25, 2020

It is a D Style proposal. The suggestion is to state explicitly how continuation lines should be indented.

One logical line can be written as two or more lines (so called line continuation or line wrapping). One example is a long argument list, that can be made more readable if written in multiple lines. And I propose to use two indentation levels (8 spaces) for line wrapping.

So:

my_func_name(arg1,
        arg2);

instead of

my_func_name(arg1,
    arg2);

Rationale

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @belka-ew! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@FeepingCreature
Copy link
Contributor

Does this also apply to call chains? Ie.

    arg.foo
        .bar // like this
            .baz; // or like this?

If not, maybe describe the affected lines better.

@mdparker
Copy link
Member

How about:

"Continuation lines shall be indented two indentation levels beyond the first line."

Then provide a three-line example for clarity.

@belka-ew belka-ew force-pushed the wrapping-line-indent branch from ce398b3 to 021070d Compare July 15, 2020 08:57
@belka-ew belka-ew force-pushed the wrapping-line-indent branch from 021070d to ae41139 Compare July 15, 2020 11:29
@belka-ew
Copy link
Contributor Author

I added a clarification that only the breaks inside parentheses are affected.

@RazvanN7 RazvanN7 merged commit bbfb8c7 into dlang:master Jan 28, 2021
@PetarKirov
Copy link
Member

@RazvanN7 Changes to the DStyle guide can't be made solely based on one's preference. Only changes match the currently established practices can be "codified" via a lightly reviewed PR. Otherwise such changes need the consensus of the majority of active contributors.
That said, such changes don't need a DIP, since this is not change that affects any users of the language, only the contributors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants