Linux Format forums Forum Index Linux Format forums
Help, discussion, magazine feedback and more
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Integer i : "Using Loops" LXF158

 
Post new topic   Reply to topic    Linux Format forums Forum Index -> Magazine and coverdiscs
View previous topic :: View next topic  
Author Message
Nuke
LXF regular


Joined: Wed Feb 09, 2011 12:11 pm
Posts: 211
Location: Chepstow, UK

PostPosted: Thu Apr 26, 2012 11:31 am    Post subject: Integer i : "Using Loops" LXF158 Reply with quote

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.
_________________
Don't worry about the flooding. The authorities are learning lessons and monitoring.
Back to top
View user's profile Send private message
nelz
Site admin


Joined: Mon Apr 04, 2005 12:52 pm
Posts: 8365
Location: Warrington, UK

PostPosted: Thu Apr 26, 2012 12:43 pm    Post subject: Reply with quote

When I learned CS at uni, i stood for index.

That was Algol68, so a lot more modern than Fortran Razz
_________________
"Insanity: doing the same thing over and over again and expecting different results." (Albert Einstein)
Back to top
View user's profile Send private message
DavidMcCrossan
LXF regular


Joined: Fri Aug 19, 2005 10:46 am
Posts: 321

PostPosted: Thu Apr 26, 2012 5:45 pm    Post subject: Integer i : ¨Using loops¨ LXF158 Reply with quote

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
View user's profile Send private message
Nuke
LXF regular


Joined: Wed Feb 09, 2011 12:11 pm
Posts: 211
Location: Chepstow, UK

PostPosted: Thu Apr 26, 2012 7:10 pm    Post subject: Re: Integer i : ¨Using loops¨ LXF158 Reply with quote

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


_________________
Don't worry about the flooding. The authorities are learning lessons and monitoring.
Back to top
View user's profile Send private message
towy71
Moderator


Joined: Wed Apr 06, 2005 3:11 pm
Posts: 4242
Location: wild West Wales

PostPosted: Thu Apr 26, 2012 8:38 pm    Post subject: Reply with quote

i stands for interface as in gui Razz
_________________
still looking for that door into summer
Back to top
View user's profile Send private message
Xelous



Joined: Thu Apr 19, 2012 3:46 pm
Posts: 16

PostPosted: Mon Apr 30, 2012 4:27 pm    Post subject: Reply with quote

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 Laughing
Back to top
View user's profile Send private message
carl_h



Joined: Sat Jul 02, 2005 1:53 pm
Posts: 10

PostPosted: Fri Jun 01, 2012 3:19 pm    Post subject: Re: Integer i : "Using Loops" LXF158 Reply with quote

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
View user's profile Send private message
Bazza
LXF regular


Joined: Sat Mar 21, 2009 11:16 am
Posts: 1462
Location: Loughborough

PostPosted: Thu Jun 07, 2012 8:50 am    Post subject: Reply with quote

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
View user's profile Send private message
einonm



Joined: Fri Apr 20, 2012 11:19 am
Posts: 29
Location: Cardiff, UK

PostPosted: Thu Jun 07, 2012 1:57 pm    Post subject: Reply with quote

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 user's profile Send private message
View previous topic :: View next topic  
Display posts from previous:   
Post new topic   Reply to topic    Linux Format forums Forum Index -> Magazine and coverdiscs All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Linux Format forums topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group


Copyright 2011 Future Publishing, all rights reserved.


Web hosting by UKFast