[Info-vax] different defaults in batch
Arne Vajhøj
arne at vajhoej.dk
Tue Nov 7 19:38:21 EST 2023
On 10/21/2023 7:51 PM, bill wrote:
> On 10/21/2023 7:44 PM, Arne Vajhøj wrote:
>> On 10/21/2023 7:22 PM, bill wrote:
>>> On 10/21/2023 5:24 PM, Johnny Billquist wrote:
>>>> On 2023-10-21 17:39, bill wrote:
>>>>> On 10/21/2023 10:55 AM, Arne Vajhøj wrote:
>>>>>> Are you telling me that you have never seen i, j, ...
>>>>>> used as variable in a for loop in C?
>>>>>>
>>>>>
>>>>> Probably, but if someone is going to use a single letter variable
>>>>> for a loop index more likely would be a, b, x, y, z. But I'm sure
>>>>> an i would show up more for it being the first letter of the word
>>>>> index than any influence from Fortran. Can't say I have ever seen
>>>>> j used.
>>>>
>>>> i and j as loop variables probably beats all other letters combined.
>>>>
>>>> If you haven't seen that, then I really wonder what code you have
>>>> looked at.
>>>>
>>>
>>> My early days doing production programming (In COBOL, Fortran, Pascal, C
>>> and a lot of different assemblers) was all done in an environment with
>>> very strict programming standards. Probably explains a lot about my
>>> style and why I don't have problems with things like over-runs and
>>> bounds violations. :-)
>>
>> C coding standards often allow or even encourage i and j.
>>
>> A few random examples:
>>
>> Linux kernel coding style:
>>
>> https://www.kernel.org/doc/html/v4.10/process/coding-style.html
>>
>> <quote>
>> LOCAL variable names should be short, and to the point. If you have
>> some random integer loop counter, it should probably be called i.
>> Calling it loop_counter is non-productive, if there is no chance of it
>> being mis-understood. Similarly, tmp can be just about any type of
>> variable that is used to hold a temporary value.
>> </quote>
>>
>> FreeBSD style guide:
>>
>> https://man.freebsd.org/cgi/man.cgi?style(9)
>>
>> <quote>
>> A for loop may declare and initialize its counting variable.
>>
>> for (int i = 0; i < 15; i++) {
>> </quote>
>>
>> Gnome coding style:
>>
>> https://developer.gnome.org/documentation/guidelines/programming/coding-style.html
>>
>> <quote>
>> for (i = 0; i < num_elements; i++) {
>> </quote>
>>
>
> To each his own. I was taught with a much stricter standard
> and I think it has done me well over my career. I will admit
> that I have used i and variants like i1 and i2 for loops when
> writing something quick and dirty that I will only be using
> myself, but even then I know deep inside that I am doing
> something basically wrong. :-)
I found this.
https://i.chzbgr.com/full/9833112832/hB64CB122/others-why-do-always-use-j-variabes-loops-programmers-disney-s-law
And immediately thought of this thread.
:-)
Arne
More information about the Info-vax
mailing list