Everything2
Near Matches
Ignore Exact
Full Text
Everything2

"i" is a meaningful variable name

created by ariels

(idea) by ariels (15 hr) (print)   ?   (I like it!) 1 C! Sun Dec 31 2000 at 16:09:19

No, really. You should always use meaningful variable names. But you should also remember that i is a variable name which means "I am an integer index". So you can -- and should -- use it where appropriate: i.e. for loops in a small scope.

Using a_idx or iIndex instead is just silly. Oh, and j, k, x, y and z are also meaningful -- when they are meaningful


(idea) by KrazyIvan (1.8 y) (print)   ?   (I like it!) Tue Mar 06 2001 at 16:59:24

The tradition of using i as a "meaningful" integer index started with the implicit variable naming technique employed in old Fortran 77 compilers. Fortran 77 implicitly casted any variable name starting with any letter between i through n as an integer. Variables that started with other letters were not cast as integers. Implicit type casting is bad coding practice.
(Don't use n for integers for the sole reason that Fortran 77 uses it. Use n because your math book uses it.)

You still have to explicitly declare variables that start with i-n (or any other letter) as an integer before using it in languages like C/C++. That's explicit type casting and C/C++ enforces strong type casting, so it's good coding practice.


printable version
chaos

Use meaningful variable names Best Practices in C/C++ Coding Make it your policy, starting now, to always answer this question honestly Learn to Program bash
Design Patterns Strong Silent Type Signs that your band practice is falling apart Guess what? I'm NOT talking to myself.
syntax error Kill only the stragglers. Let the strong ones live. Hungarian notation C/C++
I MyBase and other VB.NET concepts designed to make you feel like a five year old One True Brace computer programming
LiveJournal Open GL Touch The Truck FORTRAN
virtual The C Programming Language polymorphic Obfuscation
No more writeups are being accepted for this node. If you have something to contribute to this node, contact an Editor and arrange a review of your contribution. If you feel you have something to add to this node, post it on your Scratch Pad and contact an editor.
  Epicenter
Login
Password

password reminder
register

Everything2 Help

Cool Staff Picks
Look at this mess the Death Borg made!
Andromeda
two-handed tapping
the fierce urgency of now
Dozenal Society of America
Sally
Colt M16
The undoing of How to cook the perfect steak
Reading tarot on the street
Sticky toffee pudding
Conan O'Brien's Commencement Speech for the Harvard Class of 2000
The stars stood still and naked
Cultural Revolution
hookah
New Writeups
Ysardo
a brother to a sister(personal)
antigravpussy
your warm whispers(personal)
Clarke
Multiculturalism(idea)
aneurin
Earl of Landaff(person)
Heitah
Pseudocide(idea)
XWiz
Google Knol(lede)
Mythi
July 24, 2008(personal)
locke baron
The fall of Earth(fiction)
BookReader
Fear the Cold(dream)
Pavlovna
Kathleen MacInnes(person)
stainedglass
1(fiction)
kalen
Three "T"s(idea)
octillion369
Undead(idea)
archiewood
Ico(fiction)
Heisenberg
Why I love Everything2(log)
Everything 2 is brought to you by the letter C and The Everything Development Company