tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Rationale for some rules in style guide



Hi,

The style guide says:
When declaring variables in functions declare them sorted by size

What is the purpose of this rule, and is it still useful? I'd rather see
the variables grouped by topic. If that rule's purpose is to help some
ancient compiler lay out the variables efficiently, I don't see a point
in keeping that rule, as modern compilers are advanced enough.

then in alphabetical order

Why does it make sense to sort variables in the order 'bottom, left,
right, top' instead of the natural pronunciation order 'top, left,
bottom, right', for example? Or 'height, width, x, y' instead of 'x, y,
width, height'?

If there's no convincing reason to keep that rule, I'd like to remove
it, falling back to common sense.

Avoid initializing variables in the declarations

Why? In functions that consist of a few small paragraphs, I like
paragraphs of this form, which are compact yet readable:

	command cmd = xmalloc(sizeof(cmd));
	cmd->name = "name";
	cmd->args = build_arguments();
	cmd->env = build_environment();

I see the point of avoiding premature initialization, but if that is the
goal, the rule should say so more clearly.

Roland


Home | Main Index | Thread Index | Old Index