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

[ranges] Tweak use of braces and whitespace #5048

Merged
merged 1 commit into from Oct 21, 2021
Merged

Conversation

tkoeppe
Copy link
Contributor

@tkoeppe tkoeppe commented Oct 21, 2021

For example:

  • Use braces symmetrically in if+else statements.
  • Consistently spell empty blocks as "{}", on the same line.
  • Indent required-clauses consistently.
  • Avoid unnecessary line breaks.

@tkoeppe
Copy link
Contributor Author

tkoeppe commented Oct 21, 2021

This is meant to be an incremental improvement, not a perfect solution.

I have some unresolved questions around how we format functions with inline definitions, in particular when there is a requires-clause.

For now, I observe the following:

  1. Functions with requires clause never have the definition on the same line.
  2. If the defintion consists of a single return statement, it is spelled { return ...; } on an unindented line. Not sure I like this, but we seem to be somewhat consistent about this.
  3. If the definition consists of multiple statements, we use Egyptian braces.

I think my preference would be for Egyptian braces always, but that would require a lot of changes.

Copy link
Member

@jensmaurer jensmaurer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, an improvement.

source/ranges.tex Outdated Show resolved Hide resolved
source/ranges.tex Show resolved Hide resolved
source/ranges.tex Show resolved Hide resolved
For example:
* Use braces symmetrically in if+else statements.
* Consistently spell empty blocks as "{}", on the same line.
* Indent required-clauses consistently.
* Avoid unnecessary line breaks.
@tkoeppe tkoeppe merged commit 3a9f398 into cplusplus:main Oct 21, 2021
@tkoeppe tkoeppe deleted the space branch October 21, 2021 14:32
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.

None yet

2 participants