Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Welcome Guest | Log In | Register | Benefits
Channels ▼
RSS

C/C++

Asymmetric Bounds, Part 4: Pragmatic Advantages



Related Reading


More Insights




Required

I have to do some programming in Matlab lately, and it is like a nightmare. Feel sorry for me :-(

JLONERO8255

Andrew, I agree with your assessment that starting an array count at 0 rather than 1 or m (limits m – n array) is intuitive on my part. I have been doing C, C++, and C# for about three decades now, and, this is just my opinion. But, I came to C from FORTRAN and old Basic many years ago (even Pascal) and my thoughts at that time were as you describe. For those in the FORTRAN and Basic mind mode, they think that the C way of setting array limits is awkward and they are used to counters that index the arrays from 1 to 42 (or 1986 to 2008). If they continue to write in Basic or FORTRAN, then it would be best for them to continue to use this logic. Somewhere, we all will need to convert from one means to the other. For example, using the 1986 to 2008 example, C users will need to subtract 1986 from the index to get the array index (and set the array limit). FORTRAN and Basic users will need to add 1986 to the index to get the array index. Strangely, it all works out for the particular language used. (Also, I am not sure how arrays can be indexed in VB.NET.)