Re: Re: strange anomalies when using an iteration variable twice in 1 function
- From: "Maarten Wiltink" <maarten@xxxxxxxxxxxxxxxxxx>
- Date: Fri, 30 Sep 2005 10:35:47 +0200
"Hans Heintz" <NOSPAMhh_000001@xxxxxxxxx> wrote in message
news:fdlpj19fsndiorio0r9l8iapndbq6a85ru@xxxxxxxxxx
[...]
> There's just no logic to the first of something being 0.
Yes there is. It's how many elements you have to skip to get at
the one with that index. The first index is zero.
> If there's some logic to the processor to
> it it should be the compilers problem and not the programmers.
Professor Wirth would seem to agree with you. Pascal has traditionally
started counding arrays at one; strings still show it. But for better
or worse, your programs have to run on physical processors at some
point and counting from zero on up is simply more efficient when
indexing memory.
Think of the C adagium that "A[i] = *(A+i)". The rightmost term is
really what happens in the processor, and having to add a constant
offset every time bears a real cost.
Groetjes,
Maarten Wiltink
.
- References:
- strange anomalies when using an iteration variable twice in 1 function
- From: Hans Heintz
- Re: strange anomalies when using an iteration variable twice in 1 function
- From: Bruce Roberts
- Re: Re: strange anomalies when using an iteration variable twice in 1 function
- From: Hans Heintz
- strange anomalies when using an iteration variable twice in 1 function
- Prev by Date: Re: Detecting Window
- Next by Date: Re: IcompleteInterface = interface(IsubInterface1, IsubInterface2, IsubInterface3) not possible ?
- Previous by thread: Re: Re: strange anomalies when using an iteration variable twice in 1 function
- Next by thread: Detecting Window
- Index(es):
Relevant Pages
|