Newsgroups: comp.lang.misc Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!barmar From: barmar@think.com (Barry Margolin) Subject: Re: About the variable 'I' (was Re: long names (was Readability of Ada)) Message-ID: <1991Apr29.015054.1898@Think.COM> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA, USA References: <12394@dog.ee.lbl.gov> <1991Apr26.034205.27308@netcom.COM> Date: Mon, 29 Apr 91 01:50:54 GMT In article <1991Apr26.034205.27308@netcom.COM> mrs@netcom.COM (Morgan Schweers) writes: > Can someone confirm (preferably in a post, so my MBX doesn't flood) >the truth/falsity of FORTRAN being the starter of 'I' as a generic loop >variable? I assume Fortran programmers used it because mathematicians used it. Take a look at most math books, and you'll see things like: n ----- \ \ > formula using i / / ----- i=0 Translated into Fortran, this is DO 10 I = 0,100 statements using I 10 CONTINUE Mathematicians seem to use only single-character names for things, making extensive use of fonts, case and alphabetic ranges to denote categories. i, j, and k are integral indexes; m and n are index limits; a, b, and c are coefficiants; x, y, and z are real variables, C and K are constants; etc. The original programmers were mathematicians, so it's not surprising that they continued to use the same conventions. > Then when I finally took FORTRAN, I discovered a possible reason. I've >never seen it documented anywhere, so I was wondering if my conjecture was >right. Any opinions? (*IF* you are lucky enough not to have programmed >in FORTRAN at any time, it's loops were only allowed to be done with >INTEGER variables, and it's INTEGERS were hardcoded. I believe 'I' was >the first integer, tho I don't remember too well after some 6+ years... Actually, the rule was that by default, any variable whose name begins with I through N (I think N was the last) is an integer, and the rest are reals. Declarations are permitted to override this default for a particular variable, and the IMPLICIT statement can be used to change the default rule. > It's interesting to note, also, that the standard structure that I've >seen people go through is 'I', then 'J', then ofttimes to 'T'. Why? I usually see K used after J. Again, this just mimics what mathematicians do. I've always assumed that I is the default index because it is the initial of the word "index". -- Barry Margolin, Thinking Machines Corp. barmar@think.com {uunet,harvard}!think!barmar