http://qs1969.pair.com?node_id=171060


in reply to Of variable {mice} and its name {man}.

Instead of an admonition ("Short variable names are bad! Unless...") I'd suggest a more generous rule:

The verbosity of a name should be proportional to its scope

If my program's a one-liner, then $i is fine for pretty much any purpose. (Although using $i as a real number would probably weird me out.) In a longer program, $i is probably too short for anything but a loop variable, or maybe an increment in a short function.

In general, I try to use the shortest name possible that doesn't need an explanatory comment. So, if I'm working with vertices:

for my $v (@verts) { ... } ... sub centroid { my @verts = @_; ... } ... package Graphics::Model; ... @Graphics::Model::vertices = ();

I guess my point is that it's not the length of the name that matters (gnarf gnarf), but whether you need to comment it.

--
The hell with paco, vote for Erudil!
/msg me if you downvote this node, please.
:wq