Are there any cases where a string variable will be allocated with anything other than zero length, or a dynamic array will be allocated with anything other than zero elements?
Mailing lists / fpc-pascal / 2011-02
String and dynamic array initialisation
5 messages · 3 people ·
- JJonas Maebe 2
- MMark Morgan Lloyd 2
- MMarco van de Voort 1
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
Mark Morgan Lloyd wroteAre there any cases where a string variable will be allocated with anything other than zero length,
In case it's a shortstring, the initial data could be anything.
or a dynamic array will be allocated with anything other than zero elements?
No.
Jonas
Are there any cases where a string variable will be allocated with anything other than…
In our previous episode, Mark Morgan Lloyd said:
Are there any cases where a string variable will be allocated with anything other than zero length, or a dynamic array will be allocated with anything other than zero elements?
Global string variables can be initialized.
var x : ansistring = 'yyy';In case it's a shortstring, the initial data could be anything. No. Jonas
Jonas Maebe wrote 11 lines
On 10 Feb 2011, at 16:21, Mark Morgan Lloyd wrote:
> Are there any cases where a string variable will be allocated with
> anything other than zero length,
In case it's a shortstring, the initial data could be anything.
> or a dynamic array will be allocated with anything other than zero
> elements?
No.
Thanks Jonas, it was mainly the dynamic array case that I was interested in. Presumably a string defined without an explicit length is a longstring and starts empty.
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk
[Opinions above are the author's, not those of his employers or colleagues]
Mark Morgan Lloyd wrotePresumably a string defined without an explicit length is a longstring
Only in case of {$h+} (which is the default in Delphi mode, but not in other modes).
and starts empty.
Yes.
Jonas
