[fpc-pascal] Where is the best place to declare an array?

Werner Van Belle werner at yellowcouch.org
Thu May 6 19:12:46 CEST 2010

Jonas Maebe wrote:
> On 06 May 2010, at 16:43, Bihar Anwar wrote:
>> If I remember this correctly, I've formerly ever read somewhere (in
>> my Delphi days) that array should be declared globally (not inside a
>> function or procedure) so that access to the array will be faster. Is
>> this correct?
> No.
That's a brief answer. How is what he is saying not true ?

A global variable can be allocated in the datasegment, meaning that the
compiler knows at comiletime what address to look for. If you allocate
things dynamically then you need to follow an extra pointer, so placing
an array in the datasegment would indeed speed up things afaik ? If not,
more than a blunt 'no' would be appreciated,

With kind regards,


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20100506/6ab743d0/attachment.sig>

More information about the fpc-pascal mailing list