It's inconsistent and ripe for bugs.
Cheers,
Andrew Pennebaker
www.yellosoft.us

Mailing lists / fpc-pascal / 2011-10
7 messages · 7 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
It's inconsistent and ripe for bugs.
Cheers,
Andrew Pennebaker
www.yellosoft.us
As far as I know it's historical. String[0] used to contain the string length (255 max). Now it may be something else.
Regards,
Andrew
It's inconsistent and ripe for bugs. Andrew Pennebaker www.yellosoft.us
Andrew Pennebaker wroteIt's inconsistent and ripe for bugs.
Array indices may start at any ordinal value (including e.g. characters, values of enumerated types, etc.), not just 0. Only dynamic arrays always start at 0 because that is how they have been "imported" from other languages.
Tomas
It's inconsistent and ripe for bugs. Andrew Pennebaker www.yellosoft.us
Andrew Pennebaker wroteIt's inconsistent and ripe for bugs.
funny thing, that... i thought the same thing when looking at the proposals and requests :LOL:
Array indices may start at any ordinal value (including e.g. characters, values of…
2011/10/21 Tomas Hajny
As said by Thomas, I think we will have to get along with string[1]. However, since I stumbled upon the string[0] mistake more than once, I take the chance to suggest a way to reduce the likelihood of it.
During compilation, by statically checking the indices used to access the string, the compiler could fire a warning (or error?) if a string[0] is found.
I think that most of the times the string[0] happens inside a for loop or similar, so a good percentage of these mistakes can be caught.
R#
_______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
Roberto P. wroteDuring compilation, by statically checking the indices used to access the string, the compiler could fire a warning (or error?) if a string[0] is found.
The compiler already does that (except for shortstrings, where string[0] is valid).
Jonas
In our previous episode, Jonas Maebe said:
Isn't the warning mode dependent? Delphi warns, or at least it did in older versions.