Re: Array indexing
- From: "Malcolm" <regniztar@xxxxxxxxxxxxxx>
- Date: Mon, 20 Nov 2006 22:23:41 -0000
"Old Wolf" <oldwolf@xxxxxxxxxxxxxx> wrote in message
Malcolm wrote:No. It is ugly. And that isn't a trival issue. When code looks like line
There are lots of problems with size_t. It looks ugly,
Introspection?
noise it becomes unreadable, and then it gets hard to maintain, and you get
bugs.
As happened to Perl and C++. size-t is admittedly only a small step in that
direction, but its a step in the wrong direction.
>
When was the last time you had a negative amount of money in your pocket?it is unsigned,
When was the last time you had a chunk of memory with
a negative size?
However you can have an negative amount in your account. Intermediate
calculations of the sizes of memory objects may give negative results.
Yes it does. C frequently has to call non-C code, or be called by it.
it doesn't interface with other languages,
C doesn't interface with other languages.
Anything that makes that process easier is a good thing.
Yes I would. The fact that char and byte are the same thing in C is a major
it is a misnomer when not used to describe a size of memory,
You should use it for describing a size of memory. Would you
also criticise 'char' because it is a misnomer when not used to
refer to a character?
headache to anyone who has had to use a non-English language. However that
is somethign we are stuck with. size_t is a newcomer which can still, just,
be syuppressed if we are determined enough to squeeze it out of our nice C
code.
It is another type swilling about. The fact that it probaly has the same
it adds another type to the pool
Usually it is an alias for an existing type
number of bits as another type is neither here nor there.
Now Bloggs writes
setpixels(size_t *x, size_t *y, size_t N)
because size_t is the right thing for an index, right?
Muggins writes
int *xvals;
int *yvals;
int N;
Because his pixel co-ordiantes are integers.
Now he calls Blogg's setpixels() routine. Oh dear. The code becomes a mass
of castings and type conversions. It's the two standards problem. We need
one standard way of representign integers in the machine.
Standard:
and complicates the language.
How would you implement malloc without size_t ?
malloc() takes an numerical type as its argument which must be an integer.
Normal application
void *malloc(int N)
{
assert(N >= 0);
}
Because on normal machines there simply isn't enough memory to overflow the
range of a singed integer, so this isn't a problem.
squeezed compiler, maybe on an embedded machine
void *malloc( unsigned long long N)
{
}
weird compiler (why not do this?)
void *malloc(double N)
{
assert(N == floor(N));
}
Don't be arrogant. Maybe you don't have the intellectual capacity to
0.5 out of 6 for you (at best)
appreciate the strength of the point being made.
--
www.personal.leeds.ac.uk/~bgy1mm
freeware games to download.
.
- Follow-Ups:
- Re: Array indexing
- From: Frederick Gotham
- Re: Array indexing
- From: santosh
- Re: Array indexing
- From: Keith Thompson
- Re: Array indexing
- From: Old Wolf
- Re: Array indexing
- From: Keith Thompson
- Re: Array indexing
- References:
- Array indexing
- From: jacob navia
- Re: Array indexing
- From: Walter Roberson
- Re: Array indexing
- From: Chris Torek
- Re: Array indexing
- From: Malcolm
- Re: Array indexing
- From: Old Wolf
- Array indexing
- Prev by Date: Re: Overview
- Next by Date: Re: Array indexing
- Previous by thread: Re: Array indexing
- Next by thread: Re: Array indexing
- Index(es):
Relevant Pages
|