For manually wrapping long lines, what is your personal heuristic for choosing places to break a line?
Assuming this line is too long, where might you break it and it what order of precedence?
double var = GetContext()->CalculateValue(element, 10.0);
Most people agree about separating parameters per line:
double var = GetContext()->CalculateValue(element,
10.0);
Does anyone break at an opening paren?
double var = GetContext()->CalculateValue(
element, 10.0);
But how bout with a dereferencing operator (or .):
double var = GetContext()
->CalculateValue(element, 10.0);
or would you:
double var = GetContext()->
CalculateValue(element, 10.0);
Any different for the assignment operator?
double var =
GetContext()->CalculateValue(element, 10.0);
or
double var
= GetContext()->CalculateValue(element, 10.0);
Any others?
If your system is procedural, you could answer like this:
- Parameter names at comma
- Before a
->or.operator - After an assignment operator
Or just post some example code!
Bonus points if you can academically justify your breaking decision.
I like to make the splits in strength of binding order, closest to the end of the line first.
So in your examples I would split at the = sign. If this still spilled over the margin I would split at the ->
The idea of splitting a line is solely for the benefit of readers (since the compile could care less). I find that mentally it is easier to mentally chunk pieces of code that are broken into logical groups.