-
Notifications
You must be signed in to change notification settings - Fork 397
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
base: master
Are you sure you want to change the base?
Conversation
@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
@@ -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. |
There was a problem hiding this comment.
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;
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Signed-off-by: Nathan Henderson <[email protected]>
b68daa3
to
944969d
Compare
Signed-off-by: Nathan Henderson [email protected]