Tom Verhoeff wrote:

On Wed, Oct 29, 2008 at 09:58:10PM +0100, Vinzent Höfler wrote:
Tom Verhoeff wrote:

I am surprised that for ShortString, the range is not
also 1 <= i <= Length(s).

IIRC Turbo Pascal only allowed you to access s[0] when range checking
was off, and similarly for s[i] with i > Length(s).
No. See transcript:

That looks rather convincing.

Borland Pascal  Version 7.0  Copyright (c) 1983,92 Borland International

However, IIRC there were some differences between Borland Pascal
and Turbo Pascal (as it was named before they marketed it as
Borland Pascal).

Yes, there were. But regarding string handling, nothing changed, at least not between TP5.5 and BP7. And I know for sure that accessing element 0 was always allowed, because it could be taken as shortcut for reading or even changing the length.

Nevertheless, this means that AnsiStrings and ShortStrings are slightly
more different than suggested in the documentation.

Well, if you put it this way, yes. With ShortStrings you rather get a maximum size (where indexing is allowed regardless of the actual length, although the behaviour could be considered more or less undefined - just like accessing uninitialized memory), whilst AnsiString's behaviour doesn't distinguish between length and (maximum) size.


Vinzent.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to