Array indexing and slicing
Georg Wrede
georg.wrede at nospam.org
Tue Apr 4 15:12:57 PDT 2006
novice2 wrote:
> Thanx, Luís Marques for reply, but...
>
>
>> When you add bounds checking or negative indexes, other operations
>> must be performed. For bounds checking a conditional
>
>
> it is not depends on syntax or index sign. this check must be
> performed (if enabled), either positive or negative index. Even more:
> we all know, source code and compiler output is not the same. and
> source code with negative indexes or other index syntax will be
> compiled into the same cpu operations, if it means the same.
>
>
>> inner loops -- plus they add footprint). For negative indexes the
>> corresponding positive offset must be calculated before accessing
>> the array index. Under some
>
>
> this is not true. when we use other syntax for some operations the
> compiler output will be the same. even if we replace some several
> operations with one syntax construction compiler can generate more
> optimized code.
>
> i just want to say, IMHO, all changes in index/slicing syntax will
> change compiler only. not generated binary.
Well, we have two separate cases. First, if the array size is known at
compile time, then all of this can be take care of without runtime
penalty. Second, if we are talking about dynamic arrays, then it does
make a difference whether we allow indexing from the end of the array.
More information about the Digitalmars-d
mailing list