F
Flash Gordon
Malcolm McLean wrote, On 14/04/07 08:57:
C has NEVER had that as the definition of what an int should be.
No it has not. It has already been pointed out that Intel have done
processors with 24 bit address busses where the compilers provided
either 16 or 32 bit ints. Check up on the x86 series of processors, they
are fairly common.
There is no such processors. All the processors around for which
compilers are providing a 32 bit int can natively and naturally handle
32 bit ints.
I'm not the only person doing financial SW. There are lots of other
people doing image processing and avionics SW.
When have you needed a negative amount of memory or needed to index
before the start of an array?
That is a matter of opinion.
Most number used may be, but there is significant demand for larger
numbers, such as in calculating the tax of a company that turns over
more than 20,000,000 of the local currency (assuming something like the
UKP or USD when you have 100 cents/pennies to the dollar/pound). In some
currencies it is even easier to need numbers above 2 billion! Note I
only say significant demand, not that this is the majority usage.
That's true of almost everything in all languages.
It is also useful for doing the actual work! In fact, if it is
No, code that uses it properly is easily reusable. Code that does not
use it, or uses it incorrectly, is harder to reuse, but that is the same
for everything.
Not in properly written code, because it is for a different purpose.
Then don't use it, no one is forcing you to.
Since it has not changed yet, despite this "problem" having occured
before in the move from "16 bit" to "32 bit" processors, I doubt it will
change in the future. Unless you find a way of creating objects with a
negative size, that is.
I doubt that will happen either, see above.
No, since it is the Unix standard and the OS developers that generally
specify the ABI. In any case, as stated else-thread, the 64 bit
processors in general (the Cray is an exception) can handle 32 bit
integers as naturally as 64 bit ones and using 32 bit integers can give
a significant performance boost by halving the amount of traffic between
the fast processor and the slow memory.
Too late, they have already hit it some time back, and the decisions
were made a LONG time before that.
The language is fine as it is, there is nothing to save it from. Of
course, if you do not like the language defined a few decades ago feel
free to use a different language.
I want a type called "int" and signed that is the size of the address
bus.
C has NEVER had that as the definition of what an int should be.
> To be fernickety about it it really needs an extra bit, but in
practise if you need over half the address space for a single array then
you can code access to it specially.
That has been the convention until now.
No it has not. It has already been pointed out that Intel have done
processors with 24 bit address busses where the compilers provided
either 16 or 32 bit ints. Check up on the x86 series of processors, they
are fairly common.
> The proposal is to change it, to
make int no longer the natural integer size for the machine.
There is no such processors. All the processors around for which
compilers are providing a 32 bit int can natively and naturally handle
32 bit ints.
The problem with size_t was that the implications weren't thought
through. I am sure the committee thought that they were adding a minor
patch to malloc() and documenting variables that hold sizes of memory.
They didn't realise the implications. The problem is that if int is 32
bits and memory is 64 bits, then every array index to an arbitrary array
needs to be a size_t. Virtually every integer, pace Flash Gordon, is
used as an array index or in intermediate calculations to derive
indices.
I'm not the only person doing financial SW. There are lots of other
people doing image processing and avionics SW.
> But since size_t is unsigned,
When have you needed a negative amount of memory or needed to index
before the start of an array?
> awkward to read,
That is a matter of opinion.
> and most
numbers are much less than 2 billion,
Most number used may be, but there is significant demand for larger
numbers, such as in calculating the tax of a company that turns over
more than 20,000,000 of the local currency (assuming something like the
UKP or USD when you have 100 cents/pennies to the dollar/pound). In some
currencies it is even easier to need numbers above 2 billion! Note I
only say significant demand, not that this is the majority usage.
> people won't use it consistently.
That's true of almost everything in all languages.
A type is a standard for passing data between functions.
It is also useful for doing the actual work! In fact, if it is
> So we'll have
the two plugs problem. It will seriously impact the reusability of C code.
No, code that uses it properly is easily reusable. Code that does not
use it, or uses it incorrectly, is harder to reuse, but that is the same
for everything.
If int is 64 bits on 64-bit machines size_t will gradually fade
away.
Not in properly written code, because it is for a different purpose.
> I'm not proposing removing the symbol from C code just yet, merely
suggesting that it isn't used except as a fix to library functions, or
in special cases.
Then don't use it, no one is forcing you to.
> Eventually we will return sizeof() to generating an
int,
Since it has not changed yet, despite this "problem" having occured
before in the move from "16 bit" to "32 bit" processors, I doubt it will
change in the future. Unless you find a way of creating objects with a
negative size, that is.
> and remove it from the string functions, so it will survive merely
as a fossil in malloc().
I doubt that will happen either, see above.
C does not have fixed size basic types. Rightly or wrongly. By
making int a fixed size of 32 bits compiler vendors are the ones making
the change, not me.
No, since it is the Unix standard and the OS developers that generally
specify the ABI. In any case, as stated else-thread, the 64 bit
processors in general (the Cray is an exception) can handle 32 bit
integers as naturally as 64 bit ones and using 32 bit integers can give
a significant performance boost by halving the amount of traffic between
the fast processor and the slow memory.
> As 64 bit machines hit the mass market,
Too late, they have already hit it some time back, and the decisions
were made a LONG time before that.
> we have a
brief chance to save our language from ANSI doing to C what they did to
C++.
The language is fine as it is, there is nothing to save it from. Of
course, if you do not like the language defined a few decades ago feel
free to use a different language.