[fpc-devel] Aligned dynamic arrays

Ryan Joseph ryan at thealchemistguild.com
Sat Mar 30 00:05:50 CET 2019

> On Mar 29, 2019, at 5:25 PM, Sven Barth via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
> Ignoring something is not an answer. At least there'd need to be a runtime error.
> Thinking about it maybe it would be better to follow Anthony's idea with the record and not try to adjust/extend a language mechanism that wasn't geared for that.

Biggest problems with records is that we can’t make arrays of records because the [] property copies the record with the getter (my other email on this never got posted). If there was a feasible way to fix that problem then dynamic arrays would be nearly obsolete anyways (probably still faster though).

 A: TAlignedArray<TPoint>;
 A.Length := 1;
 A[0].x := 100; // Doesn’t work, writes to a copy and never mutates the underlying structure.

Is there no other way to specify alignment? It would be ugly but a compiler directive could be used.

 {$dynamic-array-align 4096}
 a: array of integer;
  SetLength(a,10); // just use normal SetLength now

	Ryan Joseph

More information about the fpc-devel mailing list