The block System.Typesdeclares an array type:
TDoubleDynArray = array of Double;
If I declare the method as:
procedure func (x : TDoubleDynArray)
I notice that the argument xacts as an argument var, i.e. I can change xinside the method and I will see the changes reflected outside the method.
However, when I use
procedure func (x : array of double)
As expected, any changes to xremain in func. Although it TDoubleDynArrayappears to be array of double, it behaves differently than my own array of double. What is the explanation for this?
Update: I noticed that if I declare my own type TMyArray = array of double, I get the same behavior as TDynamicDynArray. Is this somehow related to the difference between the main types of arrays?
Test code follows
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses System.Types;
var
x : TDoubleDynArray;
y : array of double;
procedure func1 (x : TDoubleDynArray);
begin
x[0] := -999.123;
end;
procedure func2 (y : array of double);
begin
y[0] := -999.123;
end;
begin
setLength (x, 10);
func1 (x);
writeln ('TDoubleDynArray: ', x[0]);
setLength (y, 10);
y[0] := 0;
func2 (y);
writeln ('array of double: ', y[0]);
Readln;
end.
rhody