Malcolm McLean said:
If you are indexing an arbitrary-length array, effectively now it is
an error to use int.
Yes.
That's a big change from what most people would recognise as "C".
No. It's the way I've been using C ever since I learned how to do it
properly, rather than follow the Schildt-style advice I had received up
to that point.
It is also very undesireable that i, which holds the
index, is described as a "size_t" when it certainly doesn't hold a
size.
I'll agree that an index doesn't hold a size...
N, the count, doesn't hold an amount of memory either, but is
also a size_t.
....but I can't agree that it doesn't hold a count.
Thnen you've got the problem of two standards, in fact 14 standards at
last count, for holding integers.
The integer types that C90 must support (and which are required to be
integer types) are char, signed char, unsigned char, short, unsigned
short, int, unsigned int, long, unsigned long, wchar_t, size_t,
ptrdiff_t, sig_atomic_t - which is thirteen.
C99 adds long long and unsigned long long, making at least fifteen, and
then there are an indeterminate number of intsuch-and-such_t types,
making a count impractical.
Either way, your count, like your argument, is wrong.
That makes it harder and harder to
make functions fit together.
No, it doesn't.
Code is littered with casts because
cursorxy takes two int *s, whilst drawxy takes two size_ts.
The only code that is littered with casts is broken code.
The best solution is to to say "int is a type which can index any
array" which means that int must have the same number of bits as a
char pointer, which on 99% of platforms is no problem at all.
No, the best solution is to use size_t where appropriate, and int where
appropriate.
The other problem is backwards compatibility with legacy libraries.
Not a problem at all. All you have to do is recompile the library with
the new compiler. If that breaks the library, it probably wasn't a very
good library anyway.
However, as I pointed out, 64 bits of memory will be the maximum for a
long time to come.
Ha. And perhaps ha.
We mustn't damage C now purely to call a few APIs left over from
32-bit days.
C has never /had/ 32-bit days. C doesn't care how many bits a byte or an
int or a size_t or an address bus has, subject to certain basic minima
which are considerably lower than 32. Write your code to depend on
64-bit ints, and you can bet your bottom dollar it'll break one day,
and you'll be resisting the change to 128 or 256 or whatever it is out
of sheer fear of breakage. That's your problem. The solution? Stop
depending on particular sizes, and work out how to program in the
large.