[fpc-devel] Aligned dynamic arrays

Sven Barth pascaldragon at googlemail.com
Fri Mar 29 22:25:53 CET 2019


Am 29.03.2019 um 17:53 schrieb Ryan Joseph:
> First minor snag, fpc_dynarray_insert, fpc_dynarray_concat can allocate new arrays like SetLength can. Do we need to make aligned variants for these also? Using array + operators there is no possibility to set alignment.
>
> var
>    a, b: array of integer;
> begin
>    a += [1]; // no way to set alignment for a
>
>    insert(1, b, 0); // no way to set alignment for b
> end.
>
> Some options:
>
> 1) ignore the problem
> 2) make extra syntax like:
>
> 	a: array of integer; alignment = 64;
>
> 3) make another function to allocate an empty array that sets alignment
>
> 	SetAlignment(a, 64);
An empty array is Nil, changing that would lead to a whole different can 
of worms.
> 4) for insert/concat make variants like InsertAligned() and ignore + operators for aligned arrays
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.

Regards,
Sven



More information about the fpc-devel mailing list