Am 2016-04-15 um 10:26 schrieb Graeme Geldenhuys:
>> Is there also a switch
>> {$OneBasedDynArrays On} ?
>> No more confusion about first and last element index.
> You really should be using low() and high() instead. ;-)
So why do we need {$ZeroBasedStrings On} at all? ;-)
Of course, when you simply want to traverse all elements
from the first to the last you can use low() and high().
But I would not use this for strings as
for i := 1 to Length(S)
is IMO more readable than
for i := low(s) to high(S)
(where it's unclear, whether high() means the highest
*possible* or the highest *current* index).
And I often need to calculate or store indices.
Then I have to take into account where counting starts and ends
which is unintuitive in dynamic arrays (not Pascal like).
When I set
INDEX := 2;
then I always have to remind me that this means that it's the
3rd index in dynamic arrays while it's the 2nd one in strings.
_______________________________________________
fpc-pascal maillist - [email protected]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal