JRS: In article <ed*********@news4.newsguy.com>, dated Sat, 2 Sep 2006
15:22:57 remote, seen in news:comp.lang.javascript, Matt Kruse
<ne********@mattkruse.composted :
>Dr John Stockton wrote:
> i = unLoadListeners.length ; while (i--) { loop body }
It is better not to use "i" as an identifier in code that others may
read;
It is a convention across many languages to use i while iterating over
arrays, etc.
There is a convention, descending from FORTRAN, to use the letters I to
N to start the names of integer variables, and the other letters for
those of floats - but that's convenient only when the code calls for a
compatible mix of integers and floats.
That is not infrequently modified to have I..N starting the names of
counting variables, with the others as other variables, without regard
to whether the latter have integer or general values.
J K I are often used for counters, and N M L for ranges-of-count - also
only when convenient - with that being the general order of preference.
Short-name variables are appropriate for short-range purposes in code,
where it's easier to remember that J is the current counter and what it
represents than it is to type countOfHungryTabbyCats consistently -
especially in a language where variables do not have to be explicitly
declared.
In primitive times, when the ASR33 ruled as an I/O device, there was no
reason to avoid using I as a variable name; it could not be confused
with i or l or j (non-existent), nor with 1 in the available font; and
programming material was rarely mixed with ordinary text. But nowadays,
a code author generally does not know what fonts the code may later be
presented in - especially if it gets in News or on the Web.
Another reason for preferring not to use I as a variable concerns its
effect on searching files with Ctrl-F or similar; the word may also
occur in HTML text or in Javascript strings or comment either as a
capital letter or a Roman numeral.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htmjscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/TP/BP/Delphi/jscr/&c, FAQ items, links.