<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Ryan Joseph via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> schrieb am Fr., 3. Apr. 2020, 14:33:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
<br>
> On Apr 3, 2020, at 3:43 PM, Sven Barth <<a href="mailto:pascaldragon@googlemail.com" rel="noreferrer noreferrer" target="_blank">pascaldragon@googlemail.com</a>> wrote:<br>
> <br>
> 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. <br>
> <br>
<br>
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.<br>
<br>
procedure DoThis(a: array of integer); <br>
...<br>
DoThis([1,2,3]);<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">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. </div><div dir="auto"><br></div><div dir="auto">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. </div><div dir="auto"><br></div><div dir="auto">Also I didn't say that dynamic arrays can't be constant, but that they only are so if declared in a const section. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>