Using D2010, I would like to do something like this:
procedure SizeArray(var aArr: array of integer; aSize: integer);
begin
SetLength(aArr,aSize);
end;
But this does not compile. Since my "aArr" parameter is not a dynamic array, this is an open array parameter. And SetLength cannot be called. The only way I know to force a parameter to be a dynamic array is to give it a type name, for example:
type
TIntArray = array of integer;
procedure SizeArray(var aArr: TIntArray; aSize: integer);
begin
SetLength(aArr,aSize);
end;
And now the code compiles. And it works fine, for the most part, but it fails:
procedure Test;
var
a : array of integer;
begin
SizeArray(a,5);
end;
Since the types of the actual and formal parameters of var must be the same, and the compiler does not recognize the "array of integer" and "TIntArray" as identical types.
, : - var , , " ", - ?
.