[fpc-pascal] Static Initialisation of Arrays

"Vinzent Höfler" JeLlyFish.software at gmx.net
Wed Jun 30 00:24:59 CEST 2010


spir <denis.spir at gmail.com>:

> Sure, but this is just a matter of convention and support by a given
> compiler:
> 	type	Integers = array of Integer;
> 	var	ints : Integers = [1,2,3];
> could work as expected by automatically sizing, allocating and
> initialising. How else could work languages that have an array/sequence/
> list literal notation?

How else!? Are you seriously asking that?

By statically determining the array bounds from the initialization expression, of course? C does it that way, Ada does, too, other languages also. In both implementations it is still not a dynamic array, because although the space may be allocated "dynamically" (on the stack), the bounds do not change anymore, so the size remains static after the declaration.

Apart from some obscure algorithms ;) that rely on reallocation and dynamically changing the size, such a one-time allocation is even the most common use of "dynamic" arrays.


Vinzent.
-- 
GRATIS für alle GMX-Mitglieder: Die maxdome Movie-FLAT!
Jetzt freischalten unter http://portal.gmx.net/de/go/maxdome01



More information about the fpc-pascal mailing list