A dynamic array is a pointer, with a bunch of compiler magic behind it. A pointer to a dynamic array is therefore not different from a pointer to a pointer. For example:
type
TDynArray = array of Integer;
PDynArray = ^TDynArray;
var
localArray: TDynArray;
pLocalArray: PDynArray;
heapArray: PDynArray;
begin
// this is a normal local variable of an dynamic array type
SetLength(localArray, 2);
localArray[0] := 0;
localArray[1] := 1;
pLocalArray := @localArray;
// this points now to localArray
pLocalArray^[0] := 2;
// now localArray[0] is 2
// you can also use this to allocate dynamic arrays on the heap
new(heapArray);
SetLength(heapArray^, 2);
heapArray^[0] := 1;
heapArray^[1] := 0;
// And dispose the memory afterwards
dispose(heapArray);
end;
You can for example use pointer to dynamic arrays to circumvent the copy on write mechanism, but in the very most cases it is not that useful, especially if you consider that most dynamic arrays can used as pointers/c style arrays:
type
TDynamicArray = array of Integer;
PInteger = ^Integer;
var
localArray: TDynamicArray;
cStyleArray: PInteger;
begin
SetLength(localArray, 2);
cStyleArray = @localArrray[0]; // casts also work, but this is shorter
cStyleArray[0] := 1; // sets localArray[0]
cStyleArray[1] := 2; // sets localArray[1]
This way you can modify an array without triggering the copy on write mechanic. Also external libraries can't handle FPC refcounted arrays, so you need to use these C-Style Arrays instead.
That said, doing this you loose information stored in the array like the length of the array, which a pointer to an array can preserve while still avoiding the copy on write problems