Skip to contentSkip to conversation

CodingStyle fixes for drm_agpsupport

PATCH Ed Cogburn 1 participant 1 message Aug 12, 2003 8 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

Ed Cogburn

author
#8 lore raw
Quoted 21 lines · Larry McVoy
Quoted 2 lines · Jeff Garzik

Larry McVoy wrote:
are function calls at a 10-nanosecond glance. Also, having two styles of 'if' formatting in your example just screams "inconsistent" to me :)

It is inconsistent, on purpose. It's essentially like perl's

	return unless pointer;

which is a oneliner, almost like an assert().

Maybe this will help: I insist on braces on anything with indentation so that I can scan them more quickly. If I gave you a choice between

	if (!pointer) {
		return (whatever);
	}

	if (!pointer) return (whatever);
Quoted 4 lines

which one will you type more often? I actually don't care which you use,
I prefer the shorter one because I don't measure my self worth in lines of code generated, I tend to favor lines of code deleted :) But either one is fine, I tend to use the first one if it has been a problem area
and I'm likely to come back and shove in some debugging.

I prefer keeping the conditional statement separate from the condition, but either way works. One thing I've noticed though is that one line if statements are difficult to debug in a debugger because there is no way to tell by watching the current debug line whether the conditional statement was executed or not. For that reason I use a two line if. Of course, rumor has it that real programmers don't use debuggers.... :)

I would rather use the extra lines for two line if statements, then make up for that used space by avoiding unnecessary braces.