Kari - I think your intentions are correct, but you confuse the issue by using the term "natural" when what you really mean is "explict." The variables "i, j, k" are explicit relative to the culture of programmers. Anyway, for a good philosophical treatment of this issue, read: Kirsh, D. (1990). When is information explicitly represented? In P. Hanson (Ed.), Information, language, and cognition. (Volume I of The Vancouver Studies in Cognitive Science, 340-365) Vancouver, BC: University of British Columbia Press. Good luck, - Nick --- Dr. Nick V. Flor Information & Cognitive Scientist Anderson Schools of Management University of New Mexico ________________________________
From: [EMAIL PROTECTED] on behalf of Kari Laitinen Sent: Fri 3/4/2005 6:28 AM To: [email protected] Subject: Re: PPIG discuss: About natural naming As I have this obsession of using natural names, in my books I have used two-word names for index variables. My "rules" are: - strings and an arrays containing characters are indexed with character_index - an array containing references to President objects is indexed with president_index - an array containing integers is indexed with integer_index - an array containing command line parameters is indexed with parameter_index - etc. I admit that finding nice replacements for the traditional i, j, and k is quite hard. Mr. (Dr.) Kari Laitinen Oulu Institute of Technology, Finland http://www.naturalprogramming.com/ Carl Chilley wrote: > One of the joys of "short names" is that they have a habit of being both > cultural and experiential. In terms of i, j, k loop variables I have to > blame FORTRAN (in my engineering days) for that one (all vars starting with > letters I to n being integers). > > On the other hand, when writing Pascal and Modula 2 I resorted to "count", > "count-1" etc. as it defined the intent of the variable. Sadly, it did not > take me long to go back to FORTRAN habits to use I, j and k (etc.) when the > intent of the variable was obvious. > > My question is whether i, j and k are still recognised *globally* as viable > and therefore known loop counters? If so, are there other examples? > > Carl > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of > John Sturdy > Sent: 4 March 2005 11:39 > To: Richard Bartlett > Cc: [email protected] > Subject: Re: PPIG discuss: About natural naming > > OTOH, I think that some short names have come to influence what we > think of as natural, in particular > i > j > k > as loop indices! I think that by now they have become more natural > than > outer_loop_index > middle_loop_index > inner_loop_index > although I suppose calling something a "loop index" is not fully > informative... but taking as an example Warshall's algorithm (all pairs > connectivity / shortest paths) > > for i = 1 to n > for j = 1 to n > for k = 1 to n > do > if (a[i,j] & a[j,k]) > then > a[i,k] = true; > > what would it make sense to call them? In this example case, they > could be from_point_number, via_point_number, to_point_number ... but > is that how we think of them, or do we think of them as "counting loop > indices" ... in which case, perhaps we don't really think of them as > variables in the normal sense, but part of a stereotypical syntactical > construct? > > __John > > ---------------------------------------------------------------------- > PPIG Discuss List ([email protected]) > Discuss admin: http://limitlessmail.net/mailman/listinfo/discuss > Announce admin: http://limitlessmail.net/mailman/listinfo/announce > PPIG Discuss archive: http://www.mail-archive.com/discuss%40ppig.org/ > > > ---------------------------------------------------------------------- > PPIG Discuss List ([email protected]) > Discuss admin: http://limitlessmail.net/mailman/listinfo/discuss > Announce admin: http://limitlessmail.net/mailman/listinfo/announce > PPIG Discuss archive: http://www.mail-archive.com/discuss%40ppig.org/ ---------------------------------------------------------------------- PPIG Discuss List ([email protected]) Discuss admin: http://limitlessmail.net/mailman/listinfo/discuss Announce admin: http://limitlessmail.net/mailman/listinfo/announce PPIG Discuss archive: http://www.mail-archive.com/discuss%40ppig.org/ ---------------------------------------------------------------------- PPIG Discuss List ([email protected]) Discuss admin: http://limitlessmail.net/mailman/listinfo/discuss Announce admin: http://limitlessmail.net/mailman/listinfo/announce PPIG Discuss archive: http://www.mail-archive.com/discuss%40ppig.org/
