Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Retarded Coding Standards

Name: Anonymous 2012-06-22 1:20

"Always compare equality with a constant on the left, for example if (5 == maxUsers) instead of if (maxUsers == 5). If neither of the expressions being compared are constants, rewrite the condition so it is, for example if (0 == userCount - userLimit) instead of if (userCount == userLimit)."

"For consistency with the previous rule, non-equality comparisons should also be formatted using the same style. For example, use if (0 < userCount) instead of if (userCount > 0), and if (0 < userCount - userLimit) instead of if (userCount > userLimit)."

Name: Anonymous 2012-06-22 21:57

>>14
That warning needs to be made narrower, since

while(c = ...) { /* do something with c */ }

is a common idiom for processing null-terminated strings (or other things that end when they're zero). I'd suggest making it warn only if you're assign a constant or single variable, like

while(c = 5)

because that's something almost never encountered in practice. while(c = <some complex expression that returns 0 when it's time to exit the loop>) is a lot more common.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List