| View previous topic :: View next topic |
| Author |
Message |
Nuke LXF regular

Joined: Wed Feb 09, 2011 12:11 pm Posts: 134 Location: Chepstow, UK
|
Posted: Thu Apr 26, 2012 11:31 am Post subject: Integer i : "Using Loops" LXF158 |
|
|
Graham Morrison wrote :- " the initial for statement requires a variable which for some reason is nearly always called i in examples"
He is writing a bit tongue in cheek, but of course it stands for "integer".
More specifically the practice comes from Fortran, which was my first programming language. In IBM mainframe Fortran at least, all variables starting with letters between i and n were integers (geddit?) by default, and the rest were floating point. So many coders adopted this convention as a lifetime habit, and i is my own first choice for any counter. _________________ Unsolved Mysteries of the Universe No 9 :-
Why can't you buy a domestic mailbox that will take an A4 envelope without creasing? |
|
| Back to top |
|
 |
nelz Moderator

Joined: Mon Apr 04, 2005 12:52 pm Posts: 8002 Location: Warrington, UK
|
Posted: Thu Apr 26, 2012 12:43 pm Post subject: |
|
|
When I learned CS at uni, i stood for index.
That was Algol68, so a lot more modern than Fortran  _________________ Unix is user-friendly. It's just very selective about who it's friends are. |
|
| Back to top |
|
 |
DavidMcCrossan LXF regular
Joined: Fri Aug 19, 2005 10:46 am Posts: 241
|
Posted: Thu Apr 26, 2012 5:45 pm Post subject: Integer i : ¨Using loops¨ LXF158 |
|
|
Dear Nuke, you are almost certainly old to been around when there appeared a memorable cartoon in the famous American satirical mag featuring a whimsical representation of a hippy with beard, flares, sandals and guitar been wheeled out of the Courtroom as he declaimed the message ¨ a petty girl, a glass of wine and a charge of Statutory Rape...¨
Best
David |
|
| Back to top |
|
 |
Nuke LXF regular

Joined: Wed Feb 09, 2011 12:11 pm Posts: 134 Location: Chepstow, UK
|
Posted: Thu Apr 26, 2012 7:10 pm Post subject: Re: Integer i : ¨Using loops¨ LXF158 |
|
|
| DavidMcCrossan wrote: | Dear Nuke, you are almost certainly old to been around when there appeared a memorable cartoon in the famous American satirical mag featuring a whimsical representation of a hippy with beard, flares, sandals and guitar been wheeled out of the Courtroom as he declaimed the message ¨ a petty girl, a glass of wine and a charge of Statutory Rape...¨
|
Maybe, but I was never quite a contemporary of Omah Khayyam,
http://www.kellscraft.com/rubaiyatedition1.html
 _________________ Unsolved Mysteries of the Universe No 9 :-
Why can't you buy a domestic mailbox that will take an A4 envelope without creasing? |
|
| Back to top |
|
 |
towy71 Moderator

Joined: Wed Apr 06, 2005 3:11 pm Posts: 4169 Location: wild West Wales
|
Posted: Thu Apr 26, 2012 8:38 pm Post subject: |
|
|
i stands for interface as in gui  _________________ still looking for that door into summer |
|
| Back to top |
|
 |
Xelous
Joined: Thu Apr 19, 2012 3:46 pm Posts: 16
|
Posted: Mon Apr 30, 2012 4:27 pm Post subject: |
|
|
It was never important what i stood for, I've heard it called:
Index
Iterator
Increment
Integer
eye
Its no important that it means anything, but that it is simple in the code to see what is implied by the programmer... and especially to make sure not to use j as the next value somewhere in the code...
At 3am on a coding kicker full of caffeine with the room all stuffy and the dog under the desk farting merrily, trying to decipher:
for (int i = 0; i < imax; i++) {
int jmax = i + 100;
for (int j = i; j < (jmax); j++) {
Is just horrible  |
|
| Back to top |
|
 |
carl_h
Joined: Sat Jul 02, 2005 1:53 pm Posts: 10
|
Posted: Fri Jun 01, 2012 3:19 pm Post subject: Re: Integer i : "Using Loops" LXF158 |
|
|
| Nuke wrote: | | Graham Morrison wrote :- " the initial for statement requires a variable which for some reason is nearly always called i in examples" |
When I learned to program on a ZX Spectrum, I always used n, because in Sinclair Basic, for loops ended with a 'Next' statement, and 'NEXT n' was just two presses on the N key. |
|
| Back to top |
|
 |
Bazza LXF regular

Joined: Sat Mar 21, 2009 11:16 am Posts: 1381 Location: Loughborough
|
Posted: Thu Jun 07, 2012 8:50 am Post subject: |
|
|
Hey carl_h...
I always use n for a different reason - (n)umber...
(But yeah, with the speccy I was lazy too... ;o) _________________ 73...
Bazza, G0LCU...
Team AMIGA... |
|
| Back to top |
|
 |
einonm
Joined: Fri Apr 20, 2012 11:19 am Posts: 29 Location: Cardiff, UK
|
Posted: Thu Jun 07, 2012 1:57 pm Post subject: |
|
|
I never use i for variable names, have you ever tried doing a grep for 'i' to find out all the places it's used? You'll end up hitting every 'if' in the file for one thing.
As a consequence I always use 'ii' or 'jj' instead - much easier to search. |
|
| Back to top |
|
 |
| View previous topic :: View next topic |
|