Ryan Joseph via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am Fr., 3. Apr. 2020, 14:33:
> > > > > On Apr 3, 2020, at 3:43 PM, Sven Barth <pascaldra...@googlemail.com> > wrote: > > > > They are neither. They are simply a pointer to the first element and a > hidden size argument. For the pointer it is not important where it comes > from: a single element, a dynamic array, a static array. > > > > Ah, I see. In the example below the open array is still a dynamic array > right? As you said earlier dynamic arrays are never constant/static (for > now at least) and therefore [1,2,3] is a dynamic. > > procedure DoThis(a: array of integer); > ... > DoThis([1,2,3]); > No. The "[...]" for an open array parameter means "open array constructer" *not* "dynamic array constructor". And this on-the-fly open array is in fact constructed on the stack. If your DoThis would be declared with a dynamic array parameter (e.G. "specialize TArray<Integer>") then you'd in fact have a temporary dynamic array constructed on the heap. Also I didn't say that dynamic arrays can't be constant, but that they only are so if declared in a const section. Regards, Sven >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal