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

Add member initializer lists and ternary operators to coding standards #7524

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ThanHenderson
Copy link
Contributor

Signed-off-by: Nathan Henderson [email protected]

@ThanHenderson
Copy link
Contributor Author

@keithc-ca I've based these changes off our discussion. Let me know if there's something else you'd be interested in adding.

doc/CodingStandard.md Outdated Show resolved Hide resolved
doc/CodingStandard.md Outdated Show resolved Hide resolved
@@ -884,6 +918,39 @@ if (0 == a && 0 != b) { ...
end = (uint8_t*)start + size;
```

#### Continuing expessions containing binary operators
* When folding overly long lines, begin the next line with the binary operator.
* Ensure the operators are aligned.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think suggesting alignment is necessarily a good idea. I think the second and subsequent lines should be indented as continued lines would be (at least one tab). We might include an example that shows how all parts might be aligned by starting with the identity of the binary operator:

uint32_t result = 0
        + longVariableNameOrCalculation1
        + longVariableNameOrCalculation2
        + longVariableNameOrCalculation3;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll remove the suggestion of alignment in favour of suggesting consistent indentation. Though, I think the example of:

uint32_t result = longVariableNameOrCalculation1
            + longVariableNameOrCalculation2
            + longVariableNameOrCalculation3;

is sufficient.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's fine; my point, though, was that sometimes putting (what would otherwise be) the first operand on the next line is that it might clarify the relationship between the (originally) first operand and later operands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I understand. Despite similarity in naming, I wasn't trying to embed any type of (special) relationship between the longVariableNameOrCalculation operands. I think I'll leave it as described in my above comment.

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

Successfully merging this pull request may close these issues.

2 participants