<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">fpc-pascal@lists.freepascal.org</a>> schrieb am So., 15. März 2020, 19:58:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Mar 15, 2020, at 8:53 PM, Howard Page-Clark via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org" target="_blank" rel="noreferrer">fpc-pascal@lists.freepascal.org</a>> wrote:<br>
> <br>
> <br>
> With recent FPCs you can however do this:<br>
> <br>
> program test;<br>
> var<br>
> data: array[0..2] of Integer;<br>
> tmp: array of Integer = Nil;<br>
> begin<br>
> tmp := [1,2,3];<br>
> Move(tmp[0], data[0], SizeOf(data));<br>
> end.<br>
<br>
yeah I figured you can do something similar with generics:<br>
<br>
generic procedure Move<T>(source: array of T; var dest);<br>
var<br>
bytes: SizeInt;<br>
begin<br>
bytes := length(source) * sizeof(T);<br>
Move(source, dest, bytes);<br>
end;<br>
<br>
begin<br>
specialize Move<GLfloat>([0.0, 0.5, 0.0, <br>
-0.5, -0.5, 0.0, <br>
0.5, -0.5, 0.0], <br>
data.verts);<br>
end.<br>
<br>
but why doesn't open arrays already do this? an open array is just a constant array so the compiler should know the arrays are compatible for assignments.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">The message of the compiler is a bit misleading. It's a *dynamic* array that is created there, not an *open* array. Open arrays only exist when being passed directly to a parameter. </div><div dir="auto"><br></div><div dir="auto">But to answer why the compiler does not do it: because I simply have not had the time to implement it! The main point of dynamic array constructors was to have them Delphi compatible. Support for static arrays is something I have planned though (and you're not the first to ask for it). </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>