I was looking at http://stackoverflow.com/q/3780235/71200 and started experimenting. What I discovered is rather interesting.
procedure Clear(AArray: array of Integer);
var
I: Integer;
begin
for I := Low(AArray) to High(AArray) do
AArray[I] := 0;
end;
var
MyArray: array of Integer;
begin
Clear(MyArray);
end.
This simple little example shows how you can pass a Dynamic Array to a procedure using an Open Array parameter. It compiles and runs exactly as expected.
procedure Clear(AArray: array of Char);
var
I: Integer;
begin
for I := Low(AArray) to High(AArray) do
AArray[I] := #0;
end;
var
MyArray: array of Char;
begin
Clear(MyArray);
end.
Here is nearly identical code the only difference being it is using an array of Char
rather than Integer
. It does not compile. Instead the compiler spits out:
E2010 Incompatible types: 'Array' and 'Dynamic array'
Why would this be?
After searching for a while I discovered this QC report. I'm running Delphi 2009 and its still happening.