On Mon, 28 Jun 2010 18:17:47 +0200
Jürgen Hestermann <juergen.hesterm...@gmx.de> wrote:

> 
> 
> Paul Michell schrieb:
> > I realise that 'Array Of Single' declares a dynamic array, but is there 
> > any equivalent syntax for static data arrays in the same way that 
> > strings litterals are in effect, variable length static declarations.
> 
> You have to realize, that dynamic arrays are actually pointers (to the array 
> and other administration data). So you cannot define anything to such arrays 
> at declaration time because no memory is assigned to this pointer yet. You 
> have to use setlength to assign memory at runtime (just as getmem would do) 
> and only then you can fill it with data.

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?

Note that this is not much different from
        var     text : String = "abc";
since string vars must indeed be kinds of (pointed) dynamic arrays, I guess... 
(Or am I wrong on this?)

The burden caused by the absence of such a notation for dynamic arrays is 
something we can accept and get used to; what advantage does it bring? It 
forces initialisation to be written in loops (if the content nicely follows a 
pattern) or sequences of element assignemnts (else). Maybe it's only me?


Denis
________________________________

vit esse estrany ☣

spir.wikidot.com
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to