Ryan Joseph via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am So., 15. März 2020, 19:58:
> > > > On Mar 15, 2020, at 8:53 PM, Howard Page-Clark via fpc-pascal < > fpc-pascal@lists.freepascal.org> wrote: > > > > > > With recent FPCs you can however do this: > > > > program test; > > var > > data: array[0..2] of Integer; > > tmp: array of Integer = Nil; > > begin > > tmp := [1,2,3]; > > Move(tmp[0], data[0], SizeOf(data)); > > end. > > yeah I figured you can do something similar with generics: > > generic procedure Move<T>(source: array of T; var dest); > var > bytes: SizeInt; > begin > bytes := length(source) * sizeof(T); > Move(source, dest, bytes); > end; > > begin > specialize Move<GLfloat>([0.0, 0.5, 0.0, > -0.5, -0.5, 0.0, > 0.5, -0.5, 0.0], > data.verts); > end. > > 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. > 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. 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). Regards, Sven >
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal